text color

This is a discussion on text color within the C++ Programming forums, part of the General Programming Boards category; in a consoel app (dos) i know you can change the color by using something like font[1] and 1 stands ...

I always use <conio.h> and their textcolor, although it may not work for you...

Code:

textcolor(RED);
textbackground(BLACK);
clrscr();

You have to do a clrscr(); afterwards to have the changes take effect. That means that only 1 color on the screen at a time, there is a way to do it with more than 1 color, I am sure if you keep posting someone will give you the code.
Anyhow, look through conio.h for all of the colors that you can use, and I think you must always type them in capitals.
RED, BLUE, GREEN, YELLOW, LIGHTCYAN, stuff like that, check out conio.h

Hope that helps. And if I am way off topic (as usual), just ignore me (as usual )

Originally posted by Kyoto Oshiro
You have to do a clrscr(); afterwards to have the changes take effect. That means that only 1 color on the screen at a time, there is a way to do it with more than 1 color, I am sure if you keep posting someone will give you the code.

Actually the standard output methods don't work right with textcolor()/textbackground(). That's why there was cprintf() or similar in conio.h, if I remember correct(I don't have conio.h in my current compiler). With cprintf() you need the Windows's CR\LF for newline.

Originally posted by Quantrizi
Traveller's example works for all C/C++ compilers, Kyoto's example works for Dev-C++ (and maybe gcc compilers to)

Works only if it supports WinAPI. DJGPP's gcc supports that but gnu gcc doesn't.

Well, I am pretty sure only gcc compilers (like MingW, Cygin (or something like that)) have conio.h because msvc++ doesn't.
[edit]If you use textcolor() and/or textbackground(), you have to include conio.o[/edit]