Include

External code is pasted into a program using the #include directive.


Description

To re-use external code in a program, the corresponding header file must be pasted in. This is handled by the compiler when it reaches an #include directive.

To include a standard library file, try #include <foo.h>.

#include <stdio.h>

int main() {
    printf("Hello World!\n");
    return 0;
}

To include a user-created file, try #include "foo/bar.h". The compiler searches for this file in the current directory first, then scans search paths.


CategoryRicottone

C/Include (last edited 2026-06-15 13:33:10 by DominicRicottone)