#include <stdio.h> int a=0; /* This is a global variable */ void fun(void); int main(void) { int a=2; /* This is a variable local to main */ int b=3; /* This is a variable local to main */ printf("1. main_b = %d\n", b); printf("main_a = %d\n", a); foo(); printf("2. main_b = %d\n", b); } void fun(void){ int b=4; /* This is a variable local to foo */ printf("foo_a = %d\n", a); printf("foo_b = %d\n", b); }
Effects of the scope
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment