local variables can only be seen within their procedure
- by default global variables can be seen everywhere
statically defined global variables can only be seen in
the current file
- external variables must be declared
|

Storage Allocation and Storage Classes
|
By default local variables have the storage class auto,
they are allocated on the stack when the procedure is
called and their memory is released when the procedure
returns - the values of auto variables are not saved
between calls
A static local variable is not allocated on the stack, it is
allocated in the data segment, the memory for a static
variable is allocated by the compiler, the value of a static
variable is saved when its procedure returns, when the
procedure is called again it will still have the same value,
for example:
|

int count(void) {
static int calls = 1;
|
|
 |