www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/18/23:47:41

From: Flavio Poletti <poletti AT writeme DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Ascii Graphics
Date: Wed, 15 Jul 1998 13:38:31 +0200
Organization: TIN
Lines: 36
Message-ID: <35AC94B7.4BECB346@writeme.com>
References: <35A6CC9A DOT EAA AT ghg DOT net DOT extra> <6o7ah7$9hu$1 AT slave1 DOT aa DOT net> <35A7CBAD DOT 5058 AT ghg DOT net DOT extra>
Reply-To: flavpol AT tin DOT it
NNTP-Posting-Host: 212.216.183.88
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I think that cout should not be used when trying to print out something
colored. You should instead use cprintf.:

*****begin
#include <iostream.h>
#include <conio.h>

int main()
{
  int i=0;
  for(i=0; i<16; i++)
  {
    textcolor(i);
    // commented out cout << "ABCDEFG\n";
    cprintf("ABCDEFG\n\r");
  }
}

*****end

Remember that cprintf behaves differently from printf in handling '\n',
so you have to add a '\r' to be sure to go to the next line ('\n':
newline) and to go to the start of the line ('\r': carriage return).

--
Flavio Poletti
e-mail:   poletti AT writeme DOT com
web page: http://www.aspide.it/freeweb/poletti/

La libertà [americana] è lì, alla portata di tutti...
     ... come la chitarra ....
... ognuno suona come vuole ...
     ... e tutti suonano come vuole la libertà!
                                  (G. Gaber)


- Raw text -


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