tags:

views:

75

answers:

2

Hi,

I am looking for the system function to adjust background color. It was like

system("color",somecolorcodes);

Does anyone know about it?

On Windows Xp or 7!

A: 

It's "color XX" where the first X is the background and the second X is the foreground.

The codes are as following:

0 = Black   8 = Gray
1 = Blue    9 = Light Blue
2 = Green   A = Light Green
3 = Aqua    B = Light Aqua
4 = Red     C = Light Red
5 = Purple  D = Light Purple
6 = Yellow  E = Light Yellow
7 = White   F = Bright White

So basically for black text on white ground, you do

system("color 70");

Windows only, tho.

LukeN
that does it. Thank you Luken. Thank you being more intelligent than others :D.
LuckySlevin
I wouldn't call it more intelligent. By the way, if an answer is helpful, mark it as accepted - it'll increase your chances of other people answering you in the future!
LukeN
already did. Thanks.
LuckySlevin
A: 

You can use the SetConsoleTextAttribute function in Windows. This will let you output text in different colors at the same time, while calling "color" doesn't.

There are also others that are less coarse -- search for color in this listing of console functions.

Also, if you're looking for a cross-platform approach take a look, for instance, at this file from Musepack.

Artefacto
Thank you also.
LuckySlevin