C Programming • C17 baseline, standards-specific features labeled
Navigate the C Standard Library
Choose standard headers by task and use their APIs with documented preconditions.
The C library provides formatted I/O, allocation, conversions, strings and memory operations, mathematics, time, character classification, diagnostics, and more. Each family has contracts: for example, string functions expect terminated strings and memory functions operate on byte counts.
Example
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
const char *text = "2048";
char *end = NULL;
long value = strtol(text, &end, 10);
if (end == text || *end != '\0') {
return EXIT_FAILURE;
}
printf("%ld\n", value);
return EXIT_SUCCESS;
}
What to expect
2048
Key idea: Read the API contract for input constraints, return values, ownership, and error reporting before calling a library function.