Static storage class is a type of storage class. Static
storage class variables are stored in memory. The default initial value of static
storage class variables is 0 (zero), unless they are initialized explicitly.
The
scope of static storage class variables is local or blocks scope, and the life
time of the variable, persists between different function calls. Static storage
class variables are initialized only once.
Ex:
#include<stdio.h>
#include<conio.h>
void increment();
main( )
{
increment(
) ;
increment(
) ;
increment(
) ;
}
void increment( )
{
static
int i = 1 ;
printf
( "%d\n", i ) ;
i
= i + 1 ;
}
Output: 1
2
3
No comments:
Post a Comment