When I take an input of a string using scanf() function, I cannot take a line as an input. Only the first word is taken as the input. Why is it so? How can this be fixed? I am referring to C language.
Simply put:
Thescanf()function reads the sequence of characters until it encounterswhitespace(space, newline, tab, etc.).
For reading a string value with spaces, we can use either gets() or fgets() in C programming language.
Here, we will see what is the difference between gets() and fgets().
fgets()
It reads a line from the specified stream and stores it into the string pointed to by str. It stops when either (n-1) characters are read, the newline character is read, or the end-of-file is...