C Programming • C17 baseline, standards-specific features labeled
Understand C Program Structure
Separate declarations, function definitions, statements, and header inclusion.
A translation unit is preprocessed and compiled from a source file. Declarations tell the compiler about names and types; definitions provide storage or function bodies. Put reusable declarations in headers and implementations in source files.
Example
#include <stdio.h>
static int square(int value);
int main(void) {
printf("%d\n", square(6));
return 0;
}
static int square(int value) {
return value * value;
}
What to expect
36
Key idea: A function prototype lets a caller use a function before its definition appears in the file.