ReadKey like Function in C

Alan J Rosenthal flaps at dgp.toronto.edu
Wed Aug 16 23:14:22 AEST 1989


leea at ssc-vax.UUCP (Lee Carver) writes:
>In this zoo of discussion on "getch", i'd like to add a shot in
>support of "kbhit()".  In particular, I'd like kbhit to return
>ture if input is waiting (i.e. getchar will NOT block) and
>false otherwise.

That's obviously standardizable (after all, however you wrote the standard
description it would probably still conform if it always returned false, or
maybe even always true), but it differs from the ibm-pc semantics.  On ibm-pcs,
kbhit() tells you whether or not _getch()_ will block%, not getchar(), and
getch()'s semantics are that it does not block if the user has pressed any
character, whether or not they have pressed return.

On an ibm-pc, if kbhit() returns true, getchar() may still block.

ajr

% Of course, nothing really blocks on the ibm-pc, it just waits.



More information about the Comp.std.c mailing list