PDA

View Full Version : c++ text colors


xaero
12-01-2003, 09:02 PM
im working on an othello game in visual c++ and want to output certain things in red and other things in black. how can i do this? (ie i want the x's and o's in red and the board and numbers in black
any ideas?

http://homepages.udayton.edu/~pauljusm/output.jpg

Dia Kharrat
12-02-2003, 12:43 AM
You can try this function (for windows):


// Set the text attributes to draw red text
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HA NDLE), FOREGROUND_RED|FOREGROUND_INTENSITY))
...
// Set the text attributes to draw black text
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HA NDLE), FOREGROUND_BLACK|FOREGROUND_INTENSITY))


Hope that helps.