static

(5) A static variable initializes only one time in whole program. For example:

#include <stdio.h> 
static int i=10;
int main(){
    i=5;
    for(i=0;i<5;i++){
         static int a=10; //This statement will execute 
                          //only time.
         printf("%d",a++);//This statement will execute 
                          //five times.
    }   
    return 0;
}

Output: 10 11 12 13 14

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.