|
|
Multi-File Program |
|
Non-trivial C programs are always split across multiple files.
Source files have a .c extension and contain
function and variable definitions
Header files have a .h extension and contain
function declarations (prototypes)
A typical source file and its corresponding header form a logical grouping of functions (I/O, array manipulation, numerical integration, etc.)
Files that use functions defined in other files must include the header file but not the source file. This will satisfy the requirement that the compiler know about the function before its used.
The final result of a compilation is a merging, not concatenation, of the compiled source files
< Show a diagram denoting the scope of variables and functions >