The <stdio.h> header stands for Standard Input Output. It contains the definitions of constants, macros, and functions used for performing input and output operations, such as reading from the keyboard or printing to the screen.
In C, all input and output is dealt with through Streams. A stream is a logical interface to a file or a physical device.
These functions are used to send data from the program to the output device.
| Function | Purpose |
|---|---|
printf() |
Prints formatted string to stdout. |
putchar() |
Prints a single character. |
puts() |
Prints a string followed by a newline (\n). |
These functions are used to read data from the user or a device into the program.
To print different types of data with printf or read with scanf, we use Format Specifiers.
%d - Signed Integer%f - Float (Decimal)%c - Character%s - String%p - Pointer AddressBeyond the console, stdio.h is used to manage files on the disk. It uses a FILE pointer to track the state of a file stream.
Sometimes, output is stored in a temporary memory called a "buffer" and not displayed immediately. The fflush() function can be used to force the transfer of data to the device.