Jump to content
  • Advertisement
Sign in to follow this  
Darkfox

Coloured Text

This topic is 5125 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
You should figure this out!

Basically, you get the StandardOutputHandle.. - Wait, what language are you using? - and change the settings of that handle.

// Get handle
HANDLE outputHandle = GetStdHandle( STD_OUTPUT_HANDLE );
// Set color
SetConsoleTextAttribute( outputHandle, FOREGROUND_BLUE );

// Complete list of colours..
// ..here!

Share this post


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

Share this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by Darkfox
Thanks. 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. ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!