Functions & Prototypes in C

From the C cheat sheet · Functions · verified Jul 2026

Functions & Prototypes

Definitions, prototypes, and recursion.

c
// Quick Reference
int add(int a, int b);      // prototype (declaration)

int add(int a, int b) {     // definition
    return a + b;
}
💡 Declare a prototype (or include its header) before you call a function.
⚡ C passes arguments by value - pass a pointer (int *p) to modify the caller's variable.
📌 static on a function limits it to the current file; on a local var it persists across calls.
🟢 Mark pointer params const (const char *) when the function only reads through them.
functionsprototypes
Back to the full C cheat sheet