How header files work
Put declarations in a header
Headers normally contain function prototypes, type definitions, macros, and extern declarations—not ordinary function definitions.
#ifndef CALCULATOR_H
#define CALCULATOR_H
double add(double left, double right);
#endif
Define code in a source file
Include the matching header so the compiler checks that declaration and definition agree.
#include "calculator.h"
double add(double left, double right)
{
return left + right;
}
Use the right include form
Quotes search project include locations for your headers. Angle brackets select implementation or configured library headers.
#include "calculator.h"
#include <stdio.h>
Avoid duplicate definitions
Include guards prevent repeated declarations in one translation unit. Define non-static functions and global objects in exactly one .c file.