Solved

reading lines from keyboard - simple

Posted on 2000-02-26
2
192 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
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 20 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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to update multiple binary circular files in C 3 223
How to organize data in excel ? 2 112
In C, why can't I shift a 64-bit integer more than 32 bits? 13 204
Acrinis True image 2 61
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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 recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now