Header files and several sources
Put declarations in a .h file and definitions in a .c file; the IDE links them into your program.
Runs in Zerethon IDE · C (GCC 14)
Official C documentation ↗
main.c
#include <stdio.h>
#include "geometry.h"
int main(void) {
printf("%d\n", area(3, 4));
return 0;
}
geometry.h
#ifndef GEOMETRY_H
#define GEOMETRY_H
int area(int width, int height);
#endif
geometry.c
#include "geometry.h"
int area(int width, int height) {
return width * height;
}
Output
12
- Run compiles the entry together with every other
.cfile whose name does not start withmainortest_(those are separate programs with their ownmain). - Include your own headers with quotes (
"geometry.h"), standard ones with angle brackets. - Only the C standard library (musl) and
-lmmath are linked; other libraries are not installed.