Jump to content


c++ text colors


1 reply to this topic

#1 xaero

    New Member

  • Members
  • Pip
  • 1 posts

Posted 02 December 2003 - 04:02 AM

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?

Posted Image

#2 Dia

    DevMaster Staff

  • Administrators
  • 1089 posts

Posted 02 December 2003 - 07:43 AM

You can try this function (for windows):

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

Hope that helps.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users