/* scope.c */ /* different scopes of the variables */ /* Author: Weiwei Chen */ /* Date: Oct. 31. 2010 */ /*preprocessor directives*/ #include /*global variable definition*/ int i = 0; /*function declaration*/ void print_i(void); /*function defintion*/ void print_i(void) { printf("in print_i: i = %d \n", i); } /*main function*/ int main(void) { /*function local variables*/ int i = 1; printf("1. i = %d \n", i); { int i = 2; /*variable within the scope of {}*/ printf("2. i = %d \n", i); } printf("3. i = %d \n", i); print_i(); return 0; }