• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

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.
0
anemos
Asked:
anemos
1 Solution
 
cookreCommented:

Just read until scanf returns zero or EOF.
0
 
sumant032199Commented:
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now