Mega Code Archive

 
Categories / C / Code Snippets
 

Global variable and function

#include <stdio.h> int count; /* count is global */ void func1(void); void func2(void); int main(void) { count = 120; func1(); return 0; } void func1(void) { int temp; temp = count; func2(); printf("count is %d", count); /* will print 120 */ } void func2(void) { int count; for(count=1; count<10; count++) putchar('.'); }