var: 1 stVar: 1 var: 1 stVar: 2 var: 1 stVar: 3
Comments:
Memory for var is freshly allocated on the run-time stack each time
foo() is entered.
var is initialized to zero each time.
Memory for stVar is allocated just once, when the program
first starts running.
stVar is initialized just once, at that time.
Values assigned to it remain across function calls.
void foo()
{
int var=0;
static int stVar=0;
var++ ;
stVar++ ;
printf( "var: %d stVar: %d\n", var, stVar );
}