+ 2
What function we use , to accept multi word string ?
scanf() stops when space is encountered
4 Answers
+ 7
Use fgets(), never use gets() - it doesn't have size arguments and can overrun the string buffer which makes it unsafe to use. It was deprecated in C99 and removed from C11.
There is one thing to remember with fgets(). It stops at EOF or a newline, and the newline is added to the string. So you may have to remove it before doing string comparisons, file access, printing, etc.
+ 3
If you still want to use scanf() function, use it with a new line format specifier.
It's scanf("%[^\n]s", str).
Here, you'll get all the characters in the string before the "\n" character.
But I recommend the fgets() function.
+ 2
Use gets() or fgets():
https://www.sololearn.com/learn/C/2914/