8
Comments: There is a single external entity that corresponds to the
idenfifier x
. Both files file21A.c and file21C.c
refer to that one entity. The linker "knows" to create just one variable x
,
which is initialized to 8.
When foo()
is called,
it sets its local variable x
to 99,
but this is a different entity than the
external variable x
, which is unique.
/* --- file21A.c --- */ int x = 8
/* --- file21B.c --- */ foo() { int x; x = 99; }
/* --- file21B.c --- */ int x; main() { foo(); printf("%d\n", x ); system("pause"); }