Automatic Variables & External Variables
A variable declared within a function cannot be accessed directly by another function. The variable declared in main function of a program cannot be accessed directly by another function. These kind of variables are called Automatic Variables.The variable come into existence when the corresponding function is invoked and it perishes when the function terminates.
Another type of variable is called External Variable. These variables are globally accessible and its existence is permanent.
The external variables must be defined outside any function and it should be declared within the function which need to access it.The declaration is done using an explicit extern statement.
The extern declaration can be omitted when the definition of the external variable occurs in the source file before its use in a particular function. Usually extern declarations are stored in a separate file called header and can be used similar to <stdio.h> i.e. #include<header name.h>.
Sometimes usage of external variable can cause problems in a program. The variable could be modified by any function within the program, which is undesirable in majority of situations.