Formatted vs Unformatted I/O Function in C (Differences)

Input output functions in C programming falls into two categories, namely, formatted input output (I/O) functions and unformatted input output (I/O) functions. In this article we will point out major differences between them:

Difference between Formatted and Unformatted Functions

Formatted I/O functions allow to supply input or display output in user desired format.

Unformatted I/O 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.


printf() and scanf() are examples for formatted input and output functions.

getch(), getche(), getchar(), gets(), puts(), putchar() etc. are examples of unformatted input output functions.


Formatted input and output functions contain format specifier in their syntax.

Unformatted input and output functions do not contain format specifier in their syntax.


Formatted I/O functions are used for storing data more user friendly.

Unformatted I/O functions are used for storing data more compactly.


Formatted I/O functions are used with all data types.

Unformatted I/O functions are used mainly for character and string data types.


Formatted I/O Example:


#include<stdio.h>
#include<conio.h>

void main()
{
 int a;
 clrscr();
 printf(“Enter value of a:”);
 scanf(“%d”, &a);
 printf(“ a = %d”, a);
 getch();
}

Output of the above program is:

Enter value of a:5↲
a = 5

Unformatted I/O Example:


#include<stdio.h>
#include<conio.h>

void main()
{
 char ch ;
 clrscr();
 printf(“Press any character:”);
 ch = getche();
 printf(“\nYou pressed :”
 putchar(ch);
getch();
}

Output of the above program is:

Press any character: L
You pressed: L