Header Files in C
Precompiled library prototypes, inclusion syntax, and standard C headers
What is a Header File?
A Header File is a file with extension .h that contains C function declarations, macro definitions, and data types shared between several source files.
Header files enable modularity, allowing developers to reuse predefined system routines and organize large applications cleanly across files.
For example, standard input/output prototypes are gathered in <stdio.h>, mathematical routines in <math.h>, and string tools in <string.h>.
Methods of Including Header Files
Header files are incorporated using the preprocessor directive #include in two standard formats:
#include "header_file_name.h"Double Quotes Syntax (Local & Custom Files)
Directs the preprocessor to search for the header file first in the current project source directory, then in system include directories. Path names can be specified up to the 127-character standard limit.
#include <header_file_name.h>Angle Brackets Syntax (Standard System Libraries)
Directs the preprocessor to search strictly within standard system library directories (e.g., standard C runtime headers).
Standard C Header Files Reference
Nine commonly used header files that play vital roles in C programming:
| Header File | Category / Primary Purpose |
|---|---|
| <assert.h> | Program diagnostic assertions and debugging verification |
| <ctype.h> | Character classification and testing functions (isalpha, isdigit, toupper) |
| <math.h> | Mathematical computations (sin, cos, sqrt, pow, log) |
| <process.h> | Process control and task spawning routines |
| <stdio.h> | Standard input and output operations (printf, scanf, fopen, fgets) |
| <stdlib.h> | General utilities, memory allocation (malloc, free), conversion, and system exit |
| <string.h> | String manipulation and memory block utilities (strcpy, strlen, memcpy) |
| <time.h> | Date, calendar time, and system clock manipulation |
| <graphics.h> | Borland/Legacy graphics drawing functions (initgraph, line, circle) |