Puzzle SL22


Rule 1.2c, 2.1, and 2.4

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.



Answer         Next Page         Previous Page Home