Header and Source Files
Separate declarations and code.
Why Split Code Into Files?
As C programs grow, keeping everything in one .c file becomes hard to read and slow to compile.
C lets you split a project into multiple files: each handles one concern. This improves organization, lets you reuse code, and means changing one part doesn't force you to recompile everything.
Two Kinds of Files
A modular C project uses two file types.
Source files (.c) contain the actual implementation: function bodies and definitions.
Header files (.h) contain declarations: function prototypes, type definitions, and macros that other files need to know about.
All lessons in this course
- Header and Source Files
- Include Guards
- extern and Linkage
- Compiling Multiple Files