#include Include headers or other source text
#include Include headers or other source text
#include inserts a header or source text into the translation unit. Search order is implementation-defined; include guards prevent duplicate definitions.
| Category | Preprocessor directives |
|---|---|
| Kind | Keyword / Statement |
| C standard | C89 / C90 |
📝 Syntax
#include <header-name>
#include "header-name"
▶ Example
Edit the C code below and click Run; the server compiles and executes it:
Output:
Standard header included
ℹ️ Info The exact search paths for angle brackets and quotes are implementation-defined. Typically, the quoted form first searches implementation-defined local locations and then proceeds as for the angle-bracket form; compiler options can add include directories.
🏷️ Related preprocessor directives
📚 Related Tutorials
❓ FAQ
QWhat is the difference between angle brackets and quotes in #include?
A#include <name> is primarily used for implementation-provided headers, while #include "name" usually searches project-related locations first. The exact search order depends on the compiler and its include-path configuration.
QWhy does a header file need an include guard?
AWhen the same header is included repeatedly, an include guard made from #ifndef, #define, and #endif skips its subsequent contents, preventing duplicate definitions within one translation unit.
QHow should I troubleshoot a header that #include cannot find?
ACheck the file name, extension, and path capitalization, then verify that the header is installed and that you are using the appropriate angle-bracket or quoted form. Next, inspect the compiler's include directories, including whether the project header directory is in the search path. Do not bypass a missing header by copying its declarations.