Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!uwvax!husc6!panda!genrad!decvax!tektronix!uw-beaver!tikal!sigma!uw-nsr!uw-warp!tom From: tom@uw-warp.UUCP Newsgroups: comp.lang.c,comp.sys.ibm.pc Subject: Re: Unbuffered I/O using MicroSoft C 3.0 Message-ID: <650@uw-warp.UUCP> Date: Sat, 24-Jan-87 19:04:28 EST Article-I.D.: uw-warp.650 Posted: Sat Jan 24 19:04:28 1987 Date-Received: Mon, 26-Jan-87 02:09:00 EST References: <1867@sunybcs.UUCP> <645@uw-warp.UUCP> Organization: The Warp, Seattle, WA Lines: 38 Summary: I was wrong - routine reads stdin, not con Xref: watmath comp.lang.c:843 comp.sys.ibm.pc:1143 In article <645@uw-warp.UUCP>, I, tom@uw-warp.UUCP (Tom May), wrote: > So, here is the promised routine which invokes MS-DOS to get a > character from the keyboard (not stdin) without echoing it. It also > does some things which are obvious from looking at the code. > > #include > int > grokchar() { > union REGS regs; > > regs.h.ah = 7; /* get char no echo */ > intdos (®s, ®s); > return (regs.h.al == 26 ? EOF : regs.h.al == '\r' ? '\n' : regs.h.al); > } It turns out that the statement about reading the keyboard, not stdin, was incorrect. Although the function is called Direct Console Input or something like that (my DOS machine + manuals are 15 miles away from my USENET machine), further inspection of the DOS Technical Reference manual reveals that all those so-called console routines actually read stdin. Even the Keyboard Input function reads stdin! (At least the doc says it does, I haven't tried it.) I discovered this when I redirected the input to a program I had written that used the above function and found that it worked, much to my surprise. Also, the MSC library routines getch() and getche() use DOS functions which read characters from stdin, not con as the manual seems to imply. I just wanted to clear this up before someone else made me look bad. :-) -- Tom May. uw-beaver!uw-nsr!uw-warp!tom