C examples for Function:Local Variable
Using a local static variable
#include <stdio.h> void trystat(void); int main(void){ int count;/*w w w . ja v a 2 s . c o m*/ for (count = 1; count <= 3; count++){ printf("Here comes iteration %d:\n", count); trystat(); } return 0; } void trystat(void) { int fade = 1; static int stay = 1; printf("fade = %d and stay = %d\n", fade++, stay++); }