delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/26/00:00:27

From: pneyz <pneyz AT bethany DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Redirecting cprintf
Date: Sun, 25 Jan 1998 20:44:04 -0800
Organization: Smoof Team
Lines: 21
Message-ID: <34CC1494.5073EDBC@bethany.edu>
References: <34CC25D9 DOT 61F6 AT swipnet DOT se>
NNTP-Posting-Host: scz-ca8-18.ix.netcom.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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


It seems to me that the reason you want to use cprintf() is for the
colors, but you cannot save colors to a file. So if you plan on using
redirection as the normal operation, then you are not getting any
benefit from cprintf() even if you could redirect it to a file. If you
need to use cprintf(), then you should just make your program capture
the screen and write it to a file (use gettext() and strip every second
byte, which is the color byte).

-- 
/*
   pneyz / Smoof Team              pneyz AT bethany DOT edu
   "Fine Malt Coding"              http://ns.bethany.edu/pneyz/
*/

- Raw text -


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