teken894
asked on
Cout color
Is there any way to change the color of the cout statements, or cin for that matter?
A simple and relatively portable way is using ansi escape sequences. On windows you might need to install ansi.sys driver
cout << "\033[31;43mHello world\n"; // red on yellow
http://www.evergreen.edu/biophysics/technotes/program/ansi_esc.htm
cout << "\033[31;43mHello world\n"; // red on yellow
http://www.evergreen.edu/biophysics/technotes/program/ansi_esc.htm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
jaime_olivares : As I am not running any unix based systems, I cannot do the ansi stuff...
__init__: also ansi.sys will make my program non-compatible with those with no ansi.sys, and im not thinking of porting, so why go throguh the trouble..
system("color //hex"); changes the overall color of the prompt.
also (FORE)(BACK)GROUND_INTENSI TY make the colors brighter, exactly what I need..
anyone know how to make orange??, I tried to no success.
__init__: also ansi.sys will make my program non-compatible with those with no ansi.sys, and im not thinking of porting, so why go throguh the trouble..
system("color //hex"); changes the overall color of the prompt.
also (FORE)(BACK)GROUND_INTENSI
anyone know how to make orange??, I tried to no success.
You can actually mix the colors, eg
ChangeColour( FOREGROUND_BLUE | FOREGROUND_RED); // Purple
but unfortunately FOREGROUND_YELLOW does not exist.
I dont think there is a way to make orange hence.
ChangeColour( FOREGROUND_BLUE | FOREGROUND_RED); // Purple
but unfortunately FOREGROUND_YELLOW does not exist.
I dont think there is a way to make orange hence.
ASKER
I made yello by mixing colors, i think it was red and green..
guess u can't use parenthesis for precedence in making orange
guess u can't use parenthesis for precedence in making orange
Nope, tried but could not figure it. You may be able to if you spend enough time playing about, but even with
WORD COLOR_YELLOW = (FOREGROUND_RED | FOREGROUND_GREEN);
ChangeColour((FOREGROUND_R ED) | COLOR_YELLOW); // Set the foreground colour to be blue
printf("This text is Orange (?)\n");
the text still comes out just the same as COLOR_YELLOW...
WORD COLOR_YELLOW = (FOREGROUND_RED | FOREGROUND_GREEN);
ChangeColour((FOREGROUND_R
printf("This text is Orange (?)\n");
the text still comes out just the same as COLOR_YELLOW...
ASKER
Thanks anyway!
No problem.
https://www.experts-exchange.com/questions/21111434/printf-can-I-print-in-color.html