C examples for Function:Global Variable
You can share the count variable between the functions.
#include <stdio.h> int count = 0; // Declare a global variable void test1(void); void test2(void); int main(void){ int count = 0; // This hides the global count for( ; count < 5 ; ++count){ test1();/* w ww. j a va 2 s .c o m*/ test2(); } return 0; } void test1(void){ printf("test1 count = %d\n", ++count); } void test2(void){ static int count; // This hides the global count printf("test2 count = %d\n", ++count); }