A static local variable causes the compiler to create permanent storage for it in much the same way that it does for a global variable. : static « Language Basics « C++ Tutorial






#include <stdio.h>    
#include <conio.h>   
     
int count(int i);   
     
int main(void)   
{   
  do {   
    count(0);   
  } while(!kbhit());   
  printf("count called %d times", count(1));   
  return 0;   
}   
     
int count(int i)   
{   
  static int c=0;   
     
  if(i) return c;   
  else c++;   
  return 0;   
}








1.12.static
1.12.1.Using a static long variable
1.12.2.Use static variable to compute a running average of numbers entered by the user
1.12.3.Initialize static member field outside the class declaration
1.12.4.A static local variable causes the compiler to create permanent storage for it in much the same way that it does for a global variable.