Static Local Variables
The keyword static can be used to force a local variable to retain its value between function calls.
For Example :-
#include <stdio.h>
void hello( void ) ;
void main ()
{
int i ;
for ( i = 0; i < 10; i++ )
hello ( ) ;
}
void hello( )
{
static int i = 1 ;
printf( “Hello World call number %d\n”, i ++ );
}
The static int i is created and initialised to 1 when the function is first called and only then. The variable retains its last value during subsequent calls to the function and is only destroyed when the program terminates.