C Basics · beginner · ~10 min
Split code across .c and .h files cleanly.
A .h header declares functions, types, and macros. A .c source file defines them. #include "foo.h" literally pastes the header into the source at that point.
Use include guards (#ifndef FOO_H / #define FOO_H / #endif) or #pragma once to prevent double-inclusion when headers include other headers. Keep headers as small as possible — they're effectively your library's public interface.
// math_utils.h
#ifndef MATH_UTILS_H
#define MATH_UTILS_H
int sum(int a, int b);
#endif
// math_utils.c
#include "math_utils.h"
int sum(int a, int b) { return a + b; }