Creating and Including Header Files

Although it's feasible to write an entire advanced C program in a single source file, accomplishing that task would be unnecessarily tedious and edits would require more effort than otherwise necessary. By using the C preprocessor, you can break complex applications down into multiple files, while still retaining the same functionality.

The #include directive provides a mechanism for including the contents of another file while compiling a primary file. You've seen this many times with the stdio.h include.

Quite often, these included files are in separate source files that exist solely to provide function declarations, macro definitions, and other nonfunction code. These included files are called header files ...

Get C Programming: Visual Quickstart Guide now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.