The C standard library is split across a handful of headers, each grouping related functions for I/O, memory, strings, math, and time. Calling the wrong one — or ignoring a return value — is a frequent source of bugs. This tool is a searchable reference covering each function’s prototype, purpose, and the pitfalls that bite C programmers.
How it works
Every function belongs to a header you must #include. The reference is grouped
by header:
stdio.h—printf,scanf,fopen,fgets,fread,fwrite,fprintf,snprintf,fclose.stdlib.h—malloc,calloc,realloc,free,atoi,strtol,qsort,bsearch,rand,exit.string.h—strlen,strcpy,strncpy,strcmp,strcat,memcpy,memmove,memset,strstr.ctype.h—isdigit,isalpha,isspace,toupper,tolower.math.h—sqrt,pow,floor,ceil,fabs,fmod.time.h—time,clock,strftime,localtime.
Worked example
#include <stdio.h>
#include <string.h>
char buf[16];
fgets(buf, sizeof buf, stdin); // bounded read — safe
buf[strcspn(buf, "\n")] = '\0'; // strip trailing newline
char dst[8];
snprintf(dst, sizeof dst, "%s", buf); // bounded copy, always NUL-terminated
fgets and snprintf take an explicit size, which is why they are preferred
over gets and strcpy.
Notes
- Return values carry the error signal:
fopenreturnsNULL, allocation functions returnNULL, and many stdio calls returnEOF. Always check. strncpydoes not guarantee a terminating'\0'if the source is exactly as long as the buffer — terminate manually.- Prefer
strtol/strtodoveratoi/atof: they report conversion errors, while theato*family silently returns 0 on bad input. - Functions tagged POSIX (
strduppre-C23,getline) are not part of plain standard C.