How to change console background and text color in c++

By
Advertisement
In c++ console window background is black and text color is white by default. You can change this color to make console window more attractive. 

Syntax:

system("color 71");

color Code in C++

This 

This statement has two parts in left side '7' is background color 
code and on right side '1' is text color code. This statement can use in main function.

You can use following color codes  :

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

Program:

#include <iostream>
using namespace std;
 
int main()
{
system("color71");
 
   cout << "This statement have two parts in left side 7 is"<<endl;
    cout<<"background color code and on right side 1 is text color "<<endl;
 cout<<"code and you can use this in main function" <<endl;
 
   return 0;
}

changing backgorund and text color in C++

1 comment: