Passive getchar?

P

Pete Ashdown

I want to read a keypress value inside a loop, but continue the loop if no key
has been pressed. In other words, I don't want to stop waiting for keypress,
but buffer it and react (differently based on the key pressed) the next time
around. What is the best way to do this?
 
E

Eric Sosman

I want to read a keypress value inside a loop, but continue the loop if no key
has been pressed. In other words, I don't want to stop waiting for keypress,
but buffer it and react (differently based on the key pressed) the next time
around. What is the best way to do this?

This is Question 19.1 on the comp.lang.c Frequently Asked
Questions (FAQ) page at <http://www.c-faq.com/>.
 
S

Seebs

I want to read a keypress value inside a loop, but continue the loop if no key
has been pressed. In other words, I don't want to stop waiting for keypress,
but buffer it and react (differently based on the key pressed) the next time
around. What is the best way to do this?

To start by identifying what kind of computer you're using, and what software
it's running, then finding a newsgroup specific to that target, since the
answers are likely to be platform-specific.

There is no way to do this that is plain old C; there are ways to do it
for Unix, old Macs, Amigas, Windows, and a few other systems. There are
some systems where you can't do it. The ways of doing it on different systems
will only work on a few specific systems, or possibly just one, usually.

-s
 

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
474,262
Messages
2,571,052
Members
48,769
Latest member
Clifft

Latest Threads

Top