Mail Archives: djgpp/1998/01/25/19:30:23
On Sun, 25 Jan 1998 21:57:46 -0800 in comp.os.msdos.djgpp Ragnar
Kellari <kellari AT swipnet DOT se> wrote:
: This is the problem:
: When I use printf the output goes to stdout and may then be redirected to
: a file but the only way I can use colors with printf is by sending
: escape-sequences to ansi.sys. Then when the output is redirected to a
: file the escape-sequence goes there aswell.
: With cprintf, redirection is not possible as the output goes directly to
: the screen.
: Does anyone have a smart solution to this problem?
I doubt it's possible to redirect conio at all. One solution, though,
would be to write a wrapper for all your printing which uses conio iff
stdout is a tty (i.e. hasn't been redirected). The `isatty' function
is good for this -- on startup, check isatty(stdout); if 0, send
output to stdout (== a file) instead of through conio.
--
george DOT foot AT merton DOT oxford DOT ac DOT uk
- Raw text -