Including Header Files

Once you create your own header file, you include it by surrounding the filename with straight double quotation marks in the directive:

#include "filename.h"

If no pathname is indicated, as in the previous code, the compiler will search the current directory, as well as other logical directories for that environment, to find the file. To eliminate this guesswork, you can use relative pathnames when including your own header files. To state that the file is in the same directory as the including (or parent) file, use an initial period followed by a slash:

#include "./filename.h"

If the file is in a subdirectory, begin with that subdirectory's name:

#include "includes/filename.h"

Finally, if the included file is located ...

Get C Programming: Visual Quickstart Guide now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.