In C, which header file contains the printf and scanf functions?

The story behind the answer

The header file containing C’s `printf` and `scanf` functions is `stdio.h`.

The name means “standard input/output.” It declares functions for formatted output, formatted input, character and string I/O, file operations, and stream handling. A C program normally includes it with `#include <stdio.h>` before calling either function.

`printf` writes formatted data to standard output, usually the terminal, while `scanf` reads formatted data from standard input. Their shared header can cause confusion because the functions perform opposite directions of data flow, but both belong to the same I/O library.

Common mix-ups include `string.h`, which handles operations on strings; `stdlib.h`, which provides utilities such as `malloc` and `strtol`; and `math.h`, which declares mathematical functions. In modern C, the angle-bracket form is preferred for standard headers, although the older `<stdio.h>` name remains the standard C spelling.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: