?
Solved

reading lines from keyboard - simple

Posted on 2000-02-26
2
Medium Priority
?
198 Views
Last Modified: 2012-05-04
what condition do you have to specify in a loop which reads words
until the user enters blank?
 I am using scanf.
0
Comment
Question by:anemos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Expert Comment

by:cookre
ID: 2561203

Just read until scanf returns zero or EOF.
0
 
LVL 3

Accepted Solution

by:
sumant032199 earned 80 total points
ID: 2561303
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question