//font color + background color
#include<windows.h> #include<iostream> #include<iomanip> using namespace std; BOOL SetConsoleColor(WORD wAttr){ HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); if(hConsole == INVALID_HANDLE_VALUE) return FALSE; return SetConsoleTextAttribute(hConsole, wAttr); } void main() { cout << "Console current background color" << endl; SetConsoleColor(FOREGROUND_RED | FOREGROUND_INTENSITY | BACKGROUND_BLUE); cout << "Set to red and blue background" << endl; SetConsoleColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); cout << "Restore to the default text background color under the console: white text and black background" << endl; }