Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!zaphod.mps.ohio-state.edu!uwm.edu!wuarchive!udel!haven!mimsy!chris From: chris@mimsy.umd.edu (Chris Torek) Newsgroups: comp.lang.c Subject: Re: How to test if a key has been hit w/o waiting for a key ? Keywords: kbhit, stdin, getchar Message-ID: <24113@mimsy.umd.edu> Date: 2 May 90 09:36:27 GMT References: <1990Apr24.000717.7882@cunixf.cc.columbia.edu> <8281@cognos.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 23 >In article <1990Apr24.000717.7882@cunixf.cc.columbia.edu> >gm@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@cognos.UUCP> jimp@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@cs.umd.edu Path: uunet!mimsy!chris