How to test if a key has been hit w/o waiting for a key ?
Chris Torek
chris at mimsy.umd.edu
Wed May 2 19:36:27 AEST 1990
>In article <1990Apr24.000717.7882 at cunixf.cc.columbia.edu>
>gm at cunixd.cc.columbia.edu (Gary Mathews) writes:
>>I want to do some computation and be able to stop by a key pressed by the
>>user.
(As I said already, this cannot be done *portably*. Given a definition
for `key pressed' and `user', it can usually be done; and it can usually
be done without resorting to writing assembly code, as I once did on VMS
so as to bypass the Pascal runtime library....)
In article <8281 at cognos.UUCP> jimp at cognos.UUCP (Jim Patterson) writes:
> ioctl( stdin->_file, FIONREAD, &count );
> count += stdin->_cnt;
Be *very* careful with this:
a. FIONREAD does not exist on all Unix systems, and on some of those
on which it does exist, it does not quite work right;
b. stdin probably does not have a _file and/or _cnt structure member
on some machines. (If you disagree, try porting to 4.4BSD when
it comes out. You may be unpleasantly surprised.)
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain: chris at cs.umd.edu Path: uunet!mimsy!chris
More information about the Comp.lang.c
mailing list