Introduction to Data Input/Output In C Programming
In C programming, input and output (I/O) operations involve the communication of data between the program and external sources or destinations. Here are the basic concepts:
The value for the input and output operations can be of any data type: integer, float, character or string depending upon the programming problem. The standard input functions like scanf(), getchar() etc are used to read user input from standard input devices while the standard output functions like printf(), putchar() are used to write the program result and data to standard output devices. Most of the standard I/O functions are defined within the stdio.h header files, hence the file is first included in the source code before writing the main() functions.
The functions for standard I/O operations are classified into two categories:
Formatted Input/Output:
Formatted I/O refers to the process of reading or writing data in a specific format, with controlled spacing, alignment, and representation. Formatted I/O functions typically use format specifiers in the function argument to define the layout of the data. Example : printf() and scanf() functions
Unformatted Input/Output:
Unformatted I/O involves reading or writing data without specific formatting instructions. Data is typically processed as a sequence of bytes. Unformatted I/O functions deal with raw data without specific formatting details. Example: getchar(), putchar(), fread(), fwrite() etc.
The diagram below summarizes different formatted Input/Output function available in C Programming: