Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!cornell!batcomputer!itsgw!steinmetz!davidsen From: davidsen@steinmetz.ge.com (William E. Davidsen Jr) Newsgroups: comp.lang.c Subject: Re: input ready under UNIX ??!!?? Keywords: input, unix, help Message-ID: <12430@steinmetz.ge.com> Date: 26 Oct 88 17:48:08 GMT References: <771@necis.UUCP> Reply-To: davidsen@crdos1.UUCP (bill davidsen) Organization: General Electric CRD, Schenectady, NY Lines: 15 Once upon a time I did this, but the source code is hiding... The basic technique is to set the input stream nonblocking and do a read of one char. If you don't get it, kbhit returns zero. If you do, push back the character (with ungetc as I recall) and return one. In any case restore the original state of the stream. On SysV you can play with the wait time, etc, to produce a function which provides "if kbhit in N secs" if it's useful. Wish I could find or remember more of the details, but this should give you a start on a solution. -- bill davidsen (wedu@ge-crd.arpa) {uunet | philabs}!steinmetz!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me