Hello. How can i change the color of text or the background?
I cant seem to find the answer anywhere on the internet but I know it can be done.
Jon
Hello. How can i change the color of text or the background?
I cant seem to find the answer anywhere on the internet but I know it can be done.
Jon
Operating Systems:
- Ubuntu 9.04
- XP
Compiler: gcc
Ok I have used that to help me change the 1st line to blue background but I cant figure out how to change the rest of the background back to black.
Put in BACKGROUND_0 somewhere, I think that's the right one.
Also, if you do the function again and don't specify any BACKGROUND_ parameters, it should skip back to black.
Write this function include windows.h header:
In program, use this:Code:void DrawColorString(string szText, int X, int Y, WORD color) { HANDLE OutputH; COORD position = {X, Y}; OutputH = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(OutputH, color); SetConsoleCursorPosition(OutputH, position); cout << szText; }
Hope this helps!Code:DrawColorString("", 0, 5, FOREGROUND_BLUE | BACKGROUND_RED);