• C

reading lines from keyboard - simple

what condition do you have to specify in a loop which reads words
until the user enters blank?
 I am using scanf.
anemosAsked:
Who is Participating?
 
sumant032199Connect With a Mentor Commented:
You can do it in one statement only using scanf()
scanf("%[^\n]s",&a_string);

The function will read input until a '\n' is detected. Put any thing you want at the place of n like A,Q or blank character, '\x0' The string will be read until that char is encountered.
0
 
cookreCommented:

Just read until scanf returns zero or EOF.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.