www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/07/03/17:54:05

From: j DOT aldrich6 AT genie DOT com
Message-Id: <199607032148.AA117650486@relay1.geis.com>
Date: Wed, 3 Jul 96 21:40:00 UTC 0000
To: djgpp AT delorie DOT com
Mime-Version: 1.0
Subject: Re: Cannot redirect getche()

Reply to message 7890269    from NORBERTJ AT PANI on 07/03/96 10:49AM


>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.

Not to sound like I'm berating you for complete stupidity or anything,
but have you bothered to read the documentation for getche()?  It
works by reading directly from the BIOS keyboard, and writing
directly to the text screen via the BIOS.  It never sends anything to
DOS, so DOS can't redirect it.  That applies to the entire family
of conio functions (getch, getche, putch, cprintf, cputs, cscanf, etc.).

OTOH, the standard i/o functions (printf, scanf, getchar, putchar, etc.)
write to stdout, which is a DOS file descriptor, and thus subject to DOS
redirection.  The same goes for stdin and stderr (and stdprn and stdaux,
technically, but it's very difficult to redirect those from DOS. ;)

John

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019