W3cubDocs

/C

Source file inclusion

Includes another source file into the current source file at the line immediately after the directive.

Syntax

#include <filename> (1)
#include "filename" (2)

Explanation

Includes source file, identified by filename, into the current source file at the line immediately after the directive.

The first version of the directive searches only standard include directories. The standard C++ library, as well as standard C library, is implicitly included in standard include directories. The standard include directories can be controlled by the user through compiler options.

Version (2) first searches the directory where the current file resides and, only if the file is not found, searches the standard include directories.

In the case the file is not found, the program is ill-formed.

References

  • C11 standard (ISO/IEC 9899:2011):
    • 6.10.2 Source file inclusion (p: 164-166)
  • C99 standard (ISO/IEC 9899:1999):
    • 6.10.2 Source file inclusion (p: 149-151)
  • C89/C90 standard (ISO/IEC 9899:1990):
    • 3.8.2 Source file inclusion

See also

c/header a list of C Standard Library header files
C++ documentation for Source file inclusion

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/c/preprocessor/include