From: George Foot Newsgroups: comp.os.msdos.djgpp Subject: Re: Redirecting cprintf Date: 26 Jan 1998 00:19:28 GMT Organization: Oxford University, England Lines: 20 Message-ID: <6agkqg$ab8$2@news.ox.ac.uk> References: <34CC25D9 DOT 61F6 AT swipnet DOT se> NNTP-Posting-Host: sable.ox.ac.uk To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk On Sun, 25 Jan 1998 21:57:46 -0800 in comp.os.msdos.djgpp Ragnar Kellari 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