Introduction
In C language, to perform the tasks we need to process data given by the programmer/user and display the results on console. C language provides Input/Output functions to carry out the tasks.
The 3 basic steps happen in a C program are,
- Input the data
- Process data & logic
- Display the results
Why I/O functions?
To conclude that the program is properly developed, programmer should feed some data to the program up on which the logic built is tested, this is done using the input functions available in C programming. Similarly, the results of the execution are intended to be displayed on the console using the output functions.
C Standard files
C language treats all devices as files. Hence, the input and output devices are also treated as standard files.
Standard File (File Pointer) | Device |
Standard Input | Keyboard |
Standard Output | Console (Screen) |
Standard Error | Your Screen |
Types of Input/Output Functions
Based on the type of the data to be processed, C language supports two types of functions for I/O operations, they are:
- Formatted functions
- Unformatted functions
Formatted functions
Formatted functions accept the data in a specific format. The standard library in C provides I/O functions such as printf() and scanf(), for printing the data on console and accepting input from keyboard respectively.