Cin Guess...I'll make it pretty at the expense of clarity!

Used to run a BBS back in the day. I have to use color. Doesn’t exactly make for clean code though…

…for anyone who is curious (for Windows) add:

#include <windows.h>

…to your header. And then in a function where you are using cout (or cin), add:

HANDLE  hConsole;
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

…and then before you “cout” you can change the color of the text with:

SetConsoleTextAttribute(hConsole, 10);

…“10” in this case is green. In the screenshot I defined a few common colors.

// 1 = Blue,	9 = Bright Blue
// 2 = Green,	10 = Bright Green
// 3 = Aqua,	11 = Bright Aqua
// 4 = Red,	12 = Bright Red
// 5 = Purple, 13 = Bright Purple
// 6 = Yellow,	14 = Bright Yellow
// 7 = White,	15 = Bright White
// 8 = Gray

…have fun!

Privacy & Terms