SyntaxFix
Write A Post
Hire A Developer
Questions
You can use the fgets() function to read a string or use scanf("%[^\n]s",name); so string reading will terminate upon encountering a newline character.
fgets()
scanf("%[^\n]s",name);