background color

can i know what is the code for background?

Please, don't use system("color"). This works more or less the same, using windows.h:
1
2
3
4
5
6
7
8
9
void SetColor(int value){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), value);
}

int main(){
SetColor(/*Number*/);
cout << "I'm in color!";
/*Your favorite pausing goes here*/
}
Edit & Run


1: Blue
2: Green
3: Cyan
4: Red
5: Purple
6: Yellow (Dark)
7: Default white
8: Gray/Grey
9: Bright blue
10: Brigth green
11: Bright cyan
12: Bright red
13: Pink/Magenta
14: Yellow
15: Bright white
-Numbers after 15 are background colors-
(taken from one of the post)

Last edited on
Topic archived. No new replies allowed.