Re: Polling for keypress
From: Floyd L. Davidson (floyd_at_barrow.com)
Date: Thu, 07 Oct 2004 15:55:29 -0800
"John Smith" <firstname.lastname@example.org> wrote:
>Thanks to both of you.
>I tried both implementations and ended up using the one from Heiko because
>even though the other was more clean it had bugs. The code Heiko posted
I would be very interested in what you think is a bug in it! It
has been being posted to Usenet for many years and evolved from
pre-POSIX code to where now it a POSIX demo.
What kind of problem did you encounter? And the big question
is, did the silly demo program work?
>works flawless though and sticks to the same specification as the function
>But I'm curious. Isn't there a unix alternative way to perform the same
The problem is that there are many alternate _tasks_, not just
the one the Window's version addresses.
The advantage of Heiko's code, for you, is exactly as you've
stated because it accomplishes what you understand is needed.
The advantage of the code that I posted is that it was meant
(for Unix, not Windows) to be a demo, not just a drop in
replacement, showing how to program that functionality on a Unix
platform. It is modularized and could be put into a library
because does not require global variables nor does it leave the
terminal in a odd state between calls. Also the kbhit() and
getch() functions are not tied at the hip, and in fact the
kbhit() function is unnecessary!
-- FloydL. Davidson <http://web.newsguy.com/floyd_davidson> Ukpeagvik (Barrow, Alaska) email@example.com