stdin and the keyboard

Lloyd Kremer kremer at cs.odu.edu
Thu Jun 27 22:45:09 AEST 1991


In article <1619 at opus.NMSU.Edu> mdowell at dante.nmsu.edu (DOWELL) writes:
>Hello,
>... dir | more.
>
>My problem is that when I get input from the command (dir) I set the
>file pointer equal to stdin, but when I go to check if a key is
>pressed getch() checks stdin and grabs a character from the command.
>
>I can't get it to recognize the keyboard and the input command 
>separate instead of both being the stdin.

If getch() is designed to read the standard input device, you'll have to
give up on it.

Opening a separate file pointer to "CON" might give you what you want.

If not, you can bypass DOS altogether and go to the BIOS level.
Interrupt 16H is the keyboard interrupt.  Doing an int 16H with AH set
to 0 will wait for a keystroke and return it in AL (keyboard scan code
in AH).  Calling with AH set to 1 will test whether a key has been pressed
and if so return it AL without removing it from the BIOS keyboard buffer.
AL = 00 if no key pressed.

For extended codes like function keys, AL = 0 and AH = extended code.

Check out functions like int86 and int86x to see how to make BIOS interrupt
calls from DOS C language.

					Lloyd Kremer
					Hilton Systems, Inc.
					kremer at cs.odu.edu



More information about the Comp.lang.c mailing list