Logo 
Search:

C Programming FAQ

Submit Interview FAQ
Home » Interview FAQ » C ProgrammingRSS Feeds

C programming practical question 42

  Shared By: Adah Miller    Date: Jan 24    Category: C Programming    Views: 83

Answer:

main()
{
extern int i;
i=20;
printf("%d",sizeof(i));
}


Answer:
Linker error: undefined symbol '_i'.


Explanation:
extern declaration specifies that the variable i is defined somewhere else. The compiler passes the external variable to be resolved by the linker. So compiler doesn't find an error. During linking the linker searches for the definition of i. Since it is not found the linker flags an error.

Share: 
 

Didn't find what you were looking for? Find more on C programming practical question 42 Or get search suggestion and latest updates.


Your Comment
  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].


Tagged: