input ready under UNIX ??!!??

William E. Davidsen Jr davidsen at steinmetz.ge.com
Thu Oct 27 03:48:08 AEST 1988


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 at ge-crd.arpa)
  {uunet | philabs}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me



More information about the Comp.lang.c mailing list