The C standard library (often called libc) ships with <stdio.h>, <stdlib.h>, <string.h>, <math.h>, and more. It is smaller than Java or Python stdlibs but covers core systems needs.
Common headers
<stdio.h>— printf, fopen, scanf<stdlib.h>— malloc, free, atoi, exit<string.h>— strlen, memcpy, strcmp<stdint.h>— fixed-width integers<stdbool.h>— bool, true, false
Portability note
Stick to standard headers for portable code. Platform extensions (POSIX, Windows API) add capabilities but tie you to an OS.
Important interview questions and answers
- Q: Where is printf declared?
A:<stdio.h> - Q: atoi pitfalls?
A: No error reporting on invalid input—preferstrtolfor robust parsing.
Self-check
- Which header declares malloc?
- Why include stdint.h in embedded code?
Interview prep
- atoi pitfalls?
No error reporting on invalid input—prefer
strtolwith end pointer and errno checks.