get one character from input at a time?

C

Chris

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
 
P

Phlip

Chris said:
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.
 
D

Daniel T.

"Phlip said:
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?
 
A

Alf P. Steinbach

* Daniel T.:
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

andy

Alf said:
* Daniel T.:

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top