Static variable example in C

/*  
  * static_c.c  
  *   
  * Copyright 2014 Afiz   
  *   
  *   
  */  
 #include <stdio.h>  
 void statfunc();   
 int main(int argc, char **argv)  
 {  
      int i=0;   
      for(i=0;i<10;i++)  
           statfunc();   
      return 0;  
 }  
 void statfunc()  
 {  
      static int stat_var=0;   
      int local_var =0;   
      printf("static valuce = %d\t Normal Variable =%d\n",stat_var, local_var);  
      stat_var++;   
      local_var++;   
 }  

Post a Comment

0 Comments