Puzzle SL31

Rule 3.1 and 3.2

Create a project consisting of several files. Here are three files:


/* --- fileA.c --- */
int x = 10;

/* --- fileB.c --- */
int x;

static int bar(int val)
{
  printf("      static bar.\n");
  return 2*val;
}

void foo()
{
  printf("    entering foo.\n");
  x = bar(x);
  printf("    exiting foo.\n");
}

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

int x;

void bar()
{
  printf("  entering extern bar x: %d\n", x);
  x += 10;
  printf("  exiting  extern bar x: %d\n", x);
}

main()
{
  printf("entering main x: %d\n", x );
  bar();
  foo();
  printf("exiting main x: %d\n", x );
}


Remember that function names are identifiers, so the rules for the linkage of identifiers applies to them.

Question: What does the project write? (Hint: pay attention to the static in fileB.c).



Answer         Next Page         Previous Page Home