← File I/O and Standard LibraryC PROGRAMMING 1.5.D

Standard Library Essentials

The parts of that come up constantly in interviews and real code.

StatusCollected
NotesChapter test: 4/5

The handful of <stdlib.h> functions that show up constantly enough to just know cold.

FunctionDoes
atoi / strtolstring to integer — strtol is the one worth actually using, since it can report where parsing stopped and detect overflow
malloc/calloc/realloc/freethe dynamic memory family from 1.2.F
qsortgeneric sort — takes a comparator function pointer, works on any array type
exit(code)terminates immediately, running registered cleanup (atexit) but skipping the rest of the call stack
rand/srandpseudo-random numbers — not seeded automatically, needs srand once at startup

atoi is the one I'd use out of habit, but it has no way to report failure — atoi("abc") just silently returns 0, identical to atoi("0"). strtol distinguishes the two by giving back an end pointer showing exactly where it stopped parsing.

Notes from readers

Comments — via GitHub