C Programming Reference


C Programming Reference >> C Basic Tutorials >> C Keywords Home >>

staticui

30/12/06 -  Views - Ratings :   3.48 of 5 / 155 Votes   

 

Static is a storage class specifier. It can be applied to any built in data type. It has different effect on local and global varaibles. When applied to global variables its scope is limited to file only ie. other files included in the program has no clue of its existence. When applied to local variables the variable is stored in global variable memmory space and not on stack. Even though the varaible has functions scope it does not get destroyed like local variable when function returns, instead it retains it value on next call. Static local varaibles are intialised only once on the first function call.

Code -
void function ( void)
{
static int a = 0;
a++;
printf ("Function have been called %d time",a);  
}

Back To Top


      

 

 

© 2006 cencyclopedia.com