Including Source Files - C Preprocessor

C examples for Preprocessor:Preprocessor Operators

Introduction

The #include directive inserts the contents of a file into the current source file.

We can include header .h file for user-defined or for standard library ones.

Library header files are enclosed between angle brackets <>.

Angle brackets <> tells the preprocessor to search for the header in the default directory to look for standard header files.

#include <stdio.h> /* search library directory */

Your own header files are enclosed within double quotes "".

The preprocessor will search for the file in the same directory as the current file.

If not found, the preprocessor will then search among the standard header files.

#include "myfile.h" /* search current, then default */

You can use use an absolute or relative path to the file in double quoted.

#include "c:\myfile.h" /* absolute path */
#include "..\myfile.h" /* relative path */

Related Tutorials