473,387 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

get one character from input at a time?

I want to find a way to get one character from input and end the stream
without pressing return.
Is there a way to do this?

Thanks for any help!
-Chris

Apr 1 '06 #1
4 3522
Chris wrote:
I want to find a way to get one character from input and end the stream
without pressing return.
Is there a way to do this?


There are allegedly several ways to do that with <iostream>.

I would just call getche() and be done with it, because I wouldn't use
iostream for formatted input.

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
Apr 1 '06 #2
In article <%K*****************@newssvr24.news.prodigy.net> ,
"Phlip" <ph******@yahoo.com> wrote:
Chris wrote:
I want to find a way to get one character from input and end the stream
without pressing return.
Is there a way to do this?


There are allegedly several ways to do that with <iostream>.


Are there? I don't think so. I think the only way to do what the OP
wants is with a non-standard library. I could be wrong though... Anybody?
--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.
Apr 1 '06 #3
* Daniel T.:
In article <%K*****************@newssvr24.news.prodigy.net> ,
"Phlip" <ph******@yahoo.com> wrote:
Chris wrote:
I want to find a way to get one character from input and end the stream
without pressing return.
Is there a way to do this?

There are allegedly several ways to do that with <iostream>.


Are there? I don't think so. I think the only way to do what the OP
wants is with a non-standard library. I could be wrong though... Anybody?


There is a way to read unbuffered on /some/ systems, but like most of
iostreams it's not guaranteed to work, so is very much less than useful.

I absolutely don't feel like digging up the details.

Someone?

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Apr 1 '06 #4
Alf P. Steinbach wrote:
* Daniel T.:
In article <%K*****************@newssvr24.news.prodigy.net> ,
"Phlip" <ph******@yahoo.com> wrote:
Chris wrote:

I want to find a way to get one character from input and end the stream
without pressing return.
Is there a way to do this?
There are allegedly several ways to do that with <iostream>.


Are there? I don't think so. I think the only way to do what the OP
wants is with a non-standard library. I could be wrong though... Anybody?


There is a way to read unbuffered on /some/ systems, but like most of
iostreams it's not guaranteed to work, so is very much less than useful.

I absolutely don't feel like digging up the details.

Someone?


Isnt the answer that the standard stream are synchronous, whereas the
OP would need an asynchronous stream and then poll it for input?

OTOH what we are looking at is an input event?... as part of an event
driven system, commonly (though not exclusiveley) the domain of a GUI,
for which lamentably there is no standard C++ Library, though such GUI
would be a great addition to the standard libraries!
regards
Andy Little

Apr 1 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Gladiator | last post by:
When I am trying to execute a program from "The C Programming Language" by Dennis Ritchie, I tried to run the following program.I am using Dev++ as a compiler software. The Program is presented...
7
by: Justin | last post by:
i need to build the unsigned character string: "PR0N\0Spam\0G1RLS\0Other\0Items\0\0\0" from the signed character string: "PR0N Spam G1RLS Other Items" Tokeninzing the character string is not...
3
by: kvnsmnsn | last post by:
I've written the following Javascript file that includes an input text field and an output text field, the latter of which is initialized to zero. Each time the user enters a number in the input...
40
by: Tameem | last post by:
hi my name is tameem. i am a new c programmer. in a c program i want to give input ""tameem"" and the output will be ""xdphhp"" in a short: the character ""a"" will be replaced by ""d"" i can...
3
by: rinu911 | last post by:
hi all I am tring to insert a values to a table by checking if the value is there in the table already but it gives me this error "Query input must contain at least one table or query" ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.