The #include Directive
#include is a preprocessor instruction that tells the preprocessor: find this file, and paste its entire text content in, right at this exact spot, before compilation continues.
Angle Brackets vs Quotes
Syntax | Example | Search behavior |
|---|---|---|
Angle brackets |
| Searches the compiler's standard system include paths — used for standard library and third-party headers |
Double quotes |
| Searches relative to the current file's directory first, then falls back to the system include paths — used for your own project headers |
#include <stdio.h> /* standard library header, angle brackets */
#include <stdlib.h>
#include "mathutils.h" /* local project header, double quotes */
int main(void)
{
printf("2 + 3 = %d\n", add(2, 3));
return 0;
}What Actually Happens at #include
There is no special magic to #include — it is a literal copy-and-paste operation performed by the preprocessor. The contents of the target file replace the #include line entirely, as if you had typed the header's text directly into your .c file at that point.
Standard Headers Are Just Text Too
Running gcc -E on a file that includes <stdio.h> shows hundreds of lines of declarations pasted in verbatim — function prototypes for printf, scanf, fopen, type definitions like FILE, and macro constants like EOF. The standard library headers are ordinary text files that go through exactly the same #include mechanism as your own project headers.
Standard library headers → angle brackets:
<stdio.h>,<stdlib.h>,<string.h>Your own project headers → double quotes:
"config.h","mathutils.h"The next two pages cover writing your own header files and protecting them from being pasted in more than once