0

Need of scanf("\n") before scanf("%[^\n]%*c")

I was trying to take input a sentence and I used the scanf("%![^\n]%*c") But errror occured. And I had to use scanf("\n") on the previous line. This is a problem in C

20th Oct 2019, 11:15 AM
Gaurav Das
Gaurav Das - avatar
2 Antworten
0
This is because the '\n' in the previous line was not scanned, so it was scanned by the next scanf(which u used) which resulted in stopping of further input due to occurence of '\n'
14th Dec 2019, 6:36 AM
kavii suri
kavii suri - avatar
- 1
Use gets() to get input as sentence
21st Oct 2019, 12:38 PM
Programmer Raja
Programmer Raja - avatar