Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!dgp.toronto.edu!flaps
From: flaps@dgp.toronto.edu (Alan J Rosenthal)
Newsgroups: comp.std.c
Subject: Re: ReadKey like Function in C
Message-ID: <1989Aug16.091422.26032@jarvis.csri.toronto.edu>
Date: 16 Aug 89 13:14:22 GMT
References: <148@trigon.UUCP> <207600029@s.cs.uiuc.edu> <941@lakesys.UUCP> <21175@cup.portal.com> <3705@buengc.BU.EDU> <10712@smoke.BRL.MIL> <3727@buengc.BU.EDU> <10721@smoke.BRL.MIL> <2851@ssc-vax.UUCP>
Lines: 18

leea@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.