Unbuffered I/O using MicroSoft C 3.0
S. John Banner
sbanner1 at uvicctr.UUCP
Fri Jan 16 05:49:46 AEST 1987
In article <645 at uw-warp.UUCP> tom at uw-warp.UUCP (Tom May) writes:
>In article <1867 at sunybcs.UUCP>, ugwayne at sunybcs (Wayne Nelligan) writes:
>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 <dos.h>
>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);
>}
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 at uvvm
sbanner1 at uvunix.UVIC.CDN
More information about the Comp.lang.c
mailing list