How extern can be used?
In which file the variable without extern to be declared?
Or there is no such restrictions?
Any C textbook should be able to explain that.
Extern is used to access global variables/functions that have been declared in another module/file.
In any file. As long as there's no ambiguity.
c-faq.com/.../hfiles.html
c-faq.com/.../extern.html
c-faq.com/.../extarraysize.html
c-faq.com/.../aryptr1.html
"Extern is used to access global variables/functions that have been declared in another module/file."
Actually, the global variables/functions must be defined in another module/file - extern provides just a declaration.
The definition is what actually creates the "object"; ie, allocates memory or generates code. Every "object" must have exactly one definition.
A declaration simply provides information that an "object" is defined elsewhere. An "object" may have many declarations.