title: First loop using structure with pointer isn't working
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  
  struct org
  {
      char name[40];
      int profit;
      int persono;
  };
  
  int main()
  {
      struct org *o;
      int i,n;
      printf(&quot;How much org :- &quot;);
      scanf(&quot;%d&quot;,&amp;n);
      o=(struct org*)calloc(n, sizeof(struct org));
      for (i=0; i&lt;n; ++i)
      {
          printf(&quot;Give the Name of Organization - &quot;);
          fgets((o+i)-&gt;name,sizeof((o+i)-&gt;name),stdin);
          (o+i)-&gt;name[strcspn((o+i)-&gt;name,&quot;\n&quot;)]='\0';
          printf(&quot;Name of company is :- %s&quot;,(o+i)-&gt;name);
      }
  
      free(o);
      return 0;
  }
  </code></pre>
  <p>The first loop isn't working please help out.
  I used fgets for this and but its working with scanf.
  And my question is Short stack overflow is making me write these lines too. Very Disgusting.</p>