O'Reilly logo

C Programming: Visual Quickstart Guide by Marc Liyanage, Larry Ullman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required