#include Directive in C
The #include directive tells the preprocessor to copy the contents of another file into the current source file before compilation. This is how you bring standard library functions and your own header files into a program.
Syntax
For standard (system) headers — use angle brackets:Common Standard Header Files
| Header | Contents |
|---|---|
<stdio.h> | printf(), scanf(), fopen(), file I/O |
<stdlib.h> | malloc(), free(), exit(), rand() |
<string.h> | strlen(), strcpy(), strcat(), strcmp() |
<math.h> | sqrt(), pow(), abs(), ceil(), floor() |
<ctype.h> | isalpha(), isdigit(), toupper(), tolower() |
<time.h> | time(), clock() |
<stdbool.h> | bool, true, false (C99+) |
Example: Including Multiple Headers
Creating Your Own Header File
mymath.h:
mymath.c:
main.c: