Static variable : static Variables « Language « C Tutorial






#include <stdio.h>

int g = 10;  

main(){

    int i =0; 
    void f1();
    f1();            
    printf(" after first call \n");
    f1();            
    printf("after second call \n");
    f1();            
    printf("after third call \n");

}
void f1()
{
    static int k=0;  
    int j = 10;             
    printf("value of k %d j %d",k,j);
    k=k+10;
}
value of k 0 j 10 after first call
      value of k 10 j 10after second call
      value of k 20 j 10after third call








1.11.static Variables
1.11.1.Static variable
1.11.2.Static versus automatic variables