4 min read
The Standard Library: An Overview
Prerequisites: Multi-file programs & header files
A few headers worth knowing exist, beyond stdio.h and string.h
already used so far:
<stdlib.h>—malloc/free,rand/srand,atoi/atof(string-to-number conversion),exit.<math.h>—sqrt,pow,floor,ceil(link with-lmon some systems:gcc file.c -o file -lm).<stdbool.h>— a realbooltype (true/false) as a readable alias over C's underlying "0 is false" rule.<time.h>—time(), used earlier to seedrand().<ctype.h>—isdigit,isalpha,toupper,tolower.
#include <math.h>
#include <stdbool.h>
bool isPositive = true;
double root = sqrt(16.0); // 4.0