+ 1
What's difference between gets() and scanf() function?
2 Antworten
+ 2
Scanf provides a format string for formatted input.
+ 2
As Sonic said Scanf() provides a format string for formatted output..
Scanf is used to take any input whether it is int, float, char or a string while gets() can take Only string as an input..
Now, question is scanf() can also take string as an input then why do we use gets()?
Answer is scanf() will take input only upto the first blank space occurs while gets() will take input upto first new line..
For eg.
Input:- Hello World
Scanf() will take input upto Hello while gets will take whole string i.e Hello World