Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ukma!widener!iggy.GW.Vitalink.COM!lll-winken!xanth!cs.odu.edu!kremer From: kremer@cs.odu.edu (Lloyd Kremer) Newsgroups: comp.lang.c Subject: Re: stdin and the keyboard Message-ID: <1991Jun27.124509.9159@cs.odu.edu> Date: 27 Jun 91 12:45:09 GMT References: <1619@opus.NMSU.Edu> Sender: news@cs.odu.edu (News File Owner) Distribution: usa Organization: Old Dominion University, Norfolk, VA Lines: 31 Nntp-Posting-Host: wisteria.cs.odu.edu In article <1619@opus.NMSU.Edu> mdowell@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@cs.odu.edu