the C standard library (at a glance)
/ libc -> LIB-see /
You do not build a house starting from raw ore — you use ready-made bricks, pipes, and wiring. The C standard library is that supply of ready-made parts: a collection of functions and types, defined by the C standard itself, that every conforming C system provides. You get input/output, text handling, math, memory allocation, and more, without writing them yourself.
It is organized into headers you include for the pieces you need. A few you will meet constantly: stdio.h for input and output, with printf() to print formatted text and scanf() to read it, plus file functions like fopen() and fread(). stdlib.h for general utilities — memory allocation with malloc() and free(), conversions like atoi(), and exit(). string.h for the null-terminated string operations: strlen() for length, strcpy() for copying, strcmp() for comparing. math.h for floating-point math like sqrt(), sin(), and pow(). A library function looks like any other function: you read its documented prototype to learn what arguments it takes and what it returns, then you call it.
Why this matters and a clarification: the standard library is the portable, guaranteed-present toolkit, so code that sticks to it runs on any conforming system. It is worth distinguishing it from the operating system's own interface: many standard functions (printf, fopen, malloc) are thin wrappers that ultimately make system calls into the kernel, but the standard library is defined by the language standard and is portable, whereas raw system calls and headers like POSIX's are platform-specific. Math functions often live in a separate library file you must explicitly link (with -lm on many systems).
#include <stdio.h> #include <string.h> int main(void) { char name[] = "world"; printf("Hello, %s (%zu chars)\n", name, strlen(name)); return 0; }
Two standard headers give us printf (stdio.h) and strlen (string.h) for free — no need to implement formatted output or string length ourselves.
The standard library is portable and defined by the language; it is not the same as the OS/POSIX system-call interface, though functions like printf and malloc ultimately call into the kernel. Math functions (math.h) often need explicit linking, e.g. gcc prog.c -lm.