Input and Output Functions in C Programming
Every C program performs three main functions i.e. it accepts data as input, processes data and produces output. Input refers to accepting of data while output refers to the presentation of data. Normally input is accepted form keyboard and output is displayed to screen. Input output operations are most common task in every programming language. C languages has different type of input output functions for input-output operations. Out of different input output operations, in this section, we mainly focus on formatted and unformatted input output functions.
Formatted Input Output Functions
Formatted input output functions accept or present the data in a particular format. The standard library consists of different functions that perform output and input operations. Out of these functions,
scanf() allow user to format input output in desired format.
scanf() can be used to read any type of data (integer, real number, character etc.).
Check our following tutorials to learn about
scanf() in detail.
Unformatted Input Output Functions
Unformatted input output functions cannot control the format of reading and writing the data. These functions are the most basic form of input and output and they do not allow to supply input or display output in user desired format that's why we call them unformatted input output functions. Unformatted input output functions are classified into two categories as character input output functions and string input output functions.
Character input functions are used to read a single character from the keyboard and character output functions are used to write a single character to a screen.
getch(), getche(), and getchar() are unformatted character input functions while
putch() and putchar() are unformatted character output functions.
Check our following tutorials to learn about different unformatted character input output functions in detail.
- getch() in detail with examples
- getche() in detail with examples
- getchar() in detail with examples
- putch() in detail with examples
- putchar() in detail with examples
In programming, collection of character is known as string or character array. In C programming, there are different input output functions available for reading and writing of strings. Most commonly used are
gets() is unformatted input function for reading string and
puts() is unformatted output function for writing string.
Check our following tutorials to learn about different unformatted string input output functions in detail.