Mail Archives: djgpp/1996/07/03/17:51:56
On 3 Jul 1996, deuce wrote:
> In a test program using getche(), the echo to the screen could not
> redirect to a file as in test >test.txt. printf() works fine.
getch() and getche() read from the console (keyboard and screen), not
from stdin. You can always redirect stdin and stdout, but the console is
always (at least in DOS) the screen and the keyboard. Well unless you
mess around with that command to read from a com port instead of the
keyboard (can't remember the name right now), but that is not a common
situation.
Anyway, there's no real way you can redirect getch() or getche(). If you
want to read from stdin, use getchar(). Be warned though, stdin (and all
streams) are read a line at a time. So to get one character, a whole line
of input must be typed in.
Justin
- Raw text -