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 the executable program is loaded into memory and it is just about to run,
there is just one x, which will hold a 32-bit 8.
Now foo() is called,
and it sets its local variable x to 99,
but this is a different entity than the
external variable x, which continues to hold its 8.
/* --- file21A.c --- */ int x = 8;
/* --- file21B.c --- */ void foo() { int x; x = 99; }
/* --- file21C.c --- */ #include <stdio.h> void foo(); int x; void main() { foo(); printf("%d\n", x ); }