2.2. Include Operation

2.2 Include Operation

The ‘#include’ directive works by directing the C preprocessor to scan the specified file as input before continuing with the rest of the current file. The output from the preprocessor contains the output already generated, followed by the output resulting from the included file, followed by the output that comes from the text after the ‘#include’ directive. For example, if you have a header file header.h as follows,

char *test (void);

and a main program called program.c that uses the header file, like this,

int x;
#include "header.h"

int
main (void)
{
  puts (test ());
}

the compiler will see the same token stream as it would if program.c read

int x;
char *test (void);

int
main (void)
{
  puts (test ());