In the C programming language, an external variable is a variable defined outside any function block. On the other hand, a local (automatic) variable is a variable defined inside a function block.
As an alternative to automatic variables, it is possible to define variables that are external to all functions, that is, variables that can be accessed by name by any function. (This mechanism is rather like FortranCOMMON or Pascal variables declared in the outermost block.)
Example
File 1:
// Explicit definition, this actually allocates
// as well as describing
int Global_Variable;
// Function prototype (declaration), assumes
// defined elsewhere, normally from include file.
void SomeFunction(void);
int main(void) {
Global_Variable = 1;
SomeFunction();
return 0;
}
File 2:
// Implicit declaration, this only describes and
// assumes allocated elsewhere, normally from include
extern int Global_Variable;
// Function header (definition)
void SomeFunction(void) {
++Global_Variable;
}