C quick reference

Common library functions on one page.

FunctionPurpose
printf / scanfFormatted output and input
fgets(buf, n, stdin)Read a line safely
strlen(s)String length
strcpy / strncpyCopy a string
strcmp(a, b)Compare strings; 0 means equal
malloc / freeGet and release heap memory
fopen / fcloseOpen and close a file
abs / randAbsolute value / random number
โ† Memory and structsC learning path โ†’