In this code:
#include<stdio.h>
int var=100;
int main()
{
extern int var; //Declaration not Definition
printf("%d\n",var);
return 0;
}
100 is printed which is nothing out of the normal, but when declaration is removed from the main(), even then the global definition is being used. How is that happening? This has been taken from K&R which says:
The (global) variable must also be declared in each function that wants to access it.