Difference between scanf() and gets()
Contents
Difference between scanf() and gets() in Tabular Form
The Key Difference between scanf() and gets() is that scanf() is used to read all types of data. While gets() is used to read-only string data.

Comparison Chart
scanf() | gets() |
---|---|
It is used to read all types of data. | It is used to read-only string data. |
It is terminated by using white space. | It is terminated by entering the key or at end of the line. |
It cannot read the white space between two words of a string. | It is used to read complete strings with white spaces. |
It requires a format specifier to read formatted data. | It can read a single string at a time, It does not require a format specifier. |
Syntax:
|
Syntax:
|
Example:
int x,y; scanf("%d%d",&x,&y);
|
Example: char ch[10]; gets(ch);
|