title: where to declare structures, inside main() or outside main()?
body: <p><strong>Case 1:</strong> structure declared outside <code>main()</code> working fine</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;conio.h&gt;
  struct prod
  {
      int price,usold;
  };
  int main()
  {
      struct prod *p,a;
  
      int billamt(struct prod *);
      int bill;
      printf("enter the values \n");
      scanf("%d%d",&amp;p-&gt;price,&amp;p-&gt;usold);
      bill=billamt(p);
      printf("bill=%d",bill);
      getch();
  }
  int billamt(struct prod *i)
  {
      int b;
      b=(i-&gt;price*i-&gt;usold);
      return b;
  }
  </code></pre>
  
  <p><strong>Case 2:</strong> declared inside <code>main()</code> giving error</p>
  
  <blockquote>
    <p>[Error] type 'main()::prod' with no linkage used to declare function 'int billamt(main()::prod*)' with linkage [-fpermissive]*</p>
  </blockquote>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;conio.h&gt;
  int main()
  {
      struct prod
  {
      int price,usold;
  };
  
  
      struct prod *p,a;
  
      int billamt(struct prod *);
      int bill;
      printf("enter the values \n");
      scanf("%d%d",&amp;p-&gt;price,&amp;p-&gt;usold);
      bill=billamt(p);
      printf("bill=%d",bill);
      getch();
  }
  int billamt(struct prod *i)
  {
      int b;
      b=(i-&gt;price*i-&gt;usold);
      return b;
  }
  </code></pre>