# Coloured Text

## Recommended Posts

Darkfox    122
Can anyone tell me how to get different coloured text in console programs. Thanks in advance.

##### Share on other sites
Pipo DeClown    804
You should figure this out!

Basically, you get the StandardOutputHandle.. - Wait, what language are you using? - and change the settings of that handle.
// Get handleHANDLE outputHandle = GetStdHandle( STD_OUTPUT_HANDLE );// Set colorSetConsoleTextAttribute( outputHandle, FOREGROUND_BLUE );// Complete list of colours..
// ..here!

##### Share on other sites
Darkfox    122
Thanks. I'm using C++ by the way. Also, what are the different colours like in your example 'FOREGROUND_BLUE'?

##### Share on other sites
And which console specificaly ? A Dos Prompt console don't need the same thing to have text color compared to a linux term (Whatever term flavor you use)

But you can look at the ncurses library, they have color management for text (and background text and that kind of thing). I don't remember if it is platform independant. If not there's pcurses I think (My memory is not very good at 5:30am;))

Just take a look in google.

Karl.

##### Share on other sites
Pipo DeClown    804
Quote:
 Original post by DarkfoxThanks. I'm using C++ by the way. Also, what are the different colours like in your example 'FOREGROUND_BLUE'?

View the '// .. here!'-link at the end of my last post. ;)