Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!brl-adm!rutgers!princeton!allegra!mit-eddie!genrad!decvax!tektronix!uw-beaver!tikal!sigma!uw-nsr!uw-warp!tom From: tom@uw-warp.UUCP Newsgroups: comp.sys.ibm.pc Subject: Re: Unbuffered I/O using MicroSoft C 3.0 Message-ID: <649@uw-warp.UUCP> Date: Thu, 22-Jan-87 05:11:56 EST Article-I.D.: uw-warp.649 Posted: Thu Jan 22 05:11:56 1987 Date-Received: Sat, 24-Jan-87 09:46:34 EST References: <1867@sunybcs.UUCP> <645@uw-warp.UUCP> <217@uvicctr.UUCP> Organization: The Warp, Seattle, WA Lines: 40 Summary: OK, there is a getch routine for unbuffered console i/o In article <217@uvicctr.UUCP>, sbanner1@uvicctr.UUCP (S. John Banner) writes: > In article <645@uw-warp.UUCP> tom@uw-warp.UUCP (Tom May) writes: > >So, here is the promised routine which invokes MS-DOS to get a > >character from the keyboard (not stdin) without echoing it. [deleted routine] > you can actually do the same thing without resorting to DOS in mscv4.0, > and I understand it works in earlyer versions as well (I got the trick > from a freind of mine using v2.something). > > grokchar() > { > while (!kbhit()) > ; > return getc(); > } > > I am not totally sure that I have the right funtion names here, but I > know they are pretty close (you might try fgetc if getc doesn't work), > and I may have the wrong name for kbhit, but the names should be pretty > obvious. > > S. John Banner > > ...!uw-beaver!uvicctr!sbanner1 > ccsjb@uvvm > sbanner1@uvunix.UVIC.CDN Actually, the following routine does the job: int grokchar () { return getch(); } This routine can also be optimized away in an obvious manner. But if your C library doesn't have a getch(), you have to do it with intdos or whatever low-level hook type stuff is available. The kbhit() is unnecessary since getch() waits for a character. Btw, kbhit() is the only weird MS-C library console i/o type extension that can't be done with an intdos, since the corresponding DOS function returns its status in the z flag, which is not in `union REGS'.-- Tom May. uw-beaver!uw-nsr!uw-warp!tom (So, do I pass the Turing test?)