Unformatted I/O functions are used only for character data type or character array/string and cannot be used for any other datatype. These functions are used to read single input from the user at the console and it allows to display the value at the console.

Why they are called unformatted I/O?  

These functions are called unformatted I/O functions because we cannot use format specifiers in these functions and hence, cannot format these functions according to our needs.

1. getch() Function :

getch() function reads a single character from the keyboard by the user but doesn’t display that character on the console screen and immediately returned without pressing enter key. This function is declared in conio.h(header file). getch() is also used for hold the screen. It has the following syntax:

ch=getch(); // where ch is a char variable.

Example:

char ctr;

ctr=getch();

2. getchar() Function:

The getchar() function is used to read only a first single character from the keyboard whether multiple characters is typed by the user and this function reads one character at one time until and unless the enter key is pressed. This function is declared in stdio.h(header file). It has the following syntax:

ch=getchar(); // where ch is a char variable.

3. putchar() Function:

The putchar() function is used to display a single character at a time by passing that character directly to it or by passing a variable that has already stored a character. This function is declared in stdio.h(header file). It has the following syntax :

putcher(ch); // where ch is a char variable.

Example :

char c='M';

putchar(c);

4. putch() Function:

putch() function is used to display a single character which is given by the user and that character prints at the current cursor location. This function is declared in conio.h(header file). It has the following syntax :

putch(ch); // where ch is a char variable.

Example:

char c='s';

putch(c);

5. getche() Function:

getche() function reads a single character from the keyboard by the user and displays it on the console screen and immediately returns without pressing the enter key. This function is declared in conio.h(header file). It has the following syntax :

ch=getche(); // where ch is a char variable.

Example:             

char ctr;            

ctr=getche();

6. gets() Function:

gets() function reads a group of characters or strings from the keyboard by the user and these characters get stored in a character array. This function allows us to write space-separated texts or strings. This function is declared in stdio.h(header file). It has the following syntax :

gets(str); // where str is a character string variable.

Example :

char str[15];

gets(str);

7. puts() Function :

In C programming puts() function is used to display a group of characters or strings which is already stored in a character array. This function is declared in stdio.h(header file). It has the following syntax :

puts(str); // where str is a string (array of characters)

Example :

char str[20]=" Hello World";

puts(str);

8. clrscr() Function:

clrscr() function is used to clear the monitor screen. It has the following syntax :

clrscr();

Note: The header file <conio.h> must include using this function in a program.

Difference between scanf() and gets()

The main difference between these two functions is that scanf() stops reading characters when it encounters a space, but gets() reads space as character too. If you enter name as sanjay kumar using scanf() it will only read and store sanjay and will leave the part after space. But gets() function will read it completely.