Answer SL29


x before foo: 8
parameter x: 999
parameter x: 25
x after  foo: 8 

/* --- fileA.c --- */
int x = 8;                /* file scope, external linkage */

 
/* --- fileB.c --- */
#include <stdio.h>

static int x = 444 ;     /* file scope, internal linkage */

void foo( int x )              /* block scope, no linkage */
{
  printf("parameter x: %d\n", x );
  x = 25;
  printf("parameter x: %d\n", x );
}

 
/* --- fileC.c --- */
#include <stdio.h>
void foo();

extern int x ;   /* file scope, external linkage */
void main()
{
  printf("x before foo: %d\n", x );
  foo( 999 );
  printf("x after  foo: %d\n", x );
}


Comments: The static int x in file fileB.c is not actually used.



Back to Puzzle Home