Teen Programmers Unite  


Return to forum top

Colors in console in C++

Posted by Faisal [send private reply] at April 22, 2002, 11:58:01 AM

The only method for colors in C++ I know is

system("color xx");

and I can't change it later on in the program.. is there some other method i could use?

Posted by RedX [send private reply] at April 22, 2002, 12:42:09 PM

That's IO and IO is system depending. What OS?


Posted by metamorphic [send private reply] at April 22, 2002, 01:46:18 PM

if you are using a console app under windows check out the following link, it shows you how to create colored text and backgrounds.

Devc++ : http://www.gametutorials.com/download/DevC++/C++/ColorText_Cpp_DEVC.zip


Posted by unknown_lamer [send private reply] at April 22, 2002, 02:58:49 PM

You can use ANSI escape codes with stdio/iostreams or you can
use something like ncurses (which is available for Windows too, I just
forgot where since I don't use Windows).

Posted by Faisal [send private reply] at April 22, 2002, 08:02:33 PM

metamporphic: that what i was looking for, but i am getting discouraged by how hard it is....

Posted by Mike_L [send private reply] at April 29, 2002, 08:12:41 PM

The Win32 console is not a nice thing. It does not come with ANSI color support. In Win9x it is possible to load a TSR like nnansi.com that renders the proper colors. This was fun to use in conjunction with ctelnet to get the colors from lscolours. ctelnet is my lame Win32 console telnet client. The telnet protocol is not happy. Better stick with simple commands or menus in Win32 console apps. Colored text is easy with the Win32 GDI.


Posted by ra_apollo [send private reply] at May 06, 2002, 05:29:02 AM

what you can simply do is go through "graphics.h" there are pre-set functions like setcolor() etc. from which you can do it much simply.

Posted by CViper [send private reply] at May 06, 2002, 10:17:57 AM

"graphics.h" does not seem to be a std header (i dont have it on any of my systems)

Posted by gian [send private reply] at May 07, 2002, 11:03:41 PM

graphics.h is a Borland specific library.

You must be logged in to post messages and see which you have already read.

Log on
Save for later automatic logon

Register as a new user
Copyright TPU 2002. See the Credits and About TPU for more information.