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

These functions allow to supply input or display output in user desired format.

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.


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.


They are used for storing data more user friendly.

They are used for storing data more compactly.


They are used with all data types.

They are used mainly for character and string data types.


Formatted I/O Examples:


#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 Examples:


#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