Rather than the answers that tell you not to use scanf()
, you can just the the Negated scanset option of scanf()
:
scanf("%99[^\n]",comment); // This will read into the string: comment
// everything from the next 99 characters up until
// it gets a newline