Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!
Lesson 8 of 10
The C Standard Library - What's Available
The C standard library is a collection of header files and functions standardised by ISO C. It covers I/O (`stdio.h`), memory (`stdlib.h`, `string.h`), mathematics (`math.h`), character classification (`ctype.h`), and more. Knowing what the standard library provides prevents you from reinventing the wheel - and knowing its limits prevents misuse.
Key Standard Library Headers
Key Standard Library Headers
#include <stdio.h> /* printf, scanf, fopen, fclose, fprintf, fgets */
#include <stdlib.h> /* malloc, calloc, realloc, free, exit, atoi, rand */
#include <string.h> /* strlen, strcpy, strncpy, strcmp, memcpy, memset */
#include <math.h> /* sqrt, pow, sin, cos, floor, ceil (link with -lm) */
#include <ctype.h> /* isdigit, isalpha, isspace, toupper, tolower */
#include <stdint.h> /* int8_t, uint32_t, int64_t, SIZE_MAX */
#include <stdbool.h> /* bool, true, false (C99) */
#include <limits.h> /* INT_MAX, CHAR_MIN, UINT_MAX */
#include <float.h> /* FLT_MAX, DBL_EPSILON */
#include <assert.h> /* assert() - crash with a message if condition is false */
#include <errno.h> /* errno, EINVAL, ENOMEM, ENOENT */
#include <time.h> /* time_t, clock(), difftime(), strftime() */
/* ── Quick examples ──────────────────────────────────────── */
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
int main(void) {
/* ctype.h - character classification */
char ch = 'a';
printf("isalpha('a')=%d toupper='%c'
", isalpha(ch), toupper(ch));
/* string.h - string utilities */
char buf[32];
strncpy(buf, "hello", sizeof(buf) - 1);
buf[sizeof(buf) - 1] = '