What does the following code write to the monitor?
/* --- fileA.c --- */ int x = 8;
/* --- fileB.c --- */ void foo() { int x; x = 99; }
/* --- fileC.c --- */ #include <stdio.h> void foo(); extern int x; void main() { foo(); printf("%d\n", x ); }
Notice that this is nearly the same as the previous puzzle except
now the keyword extern
is used in fileC.c.
The local variable x
in foo()
has no linkage.