Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Dynk

Hello world coloured text output?

This topic is 5884 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

Hey, all. I''m completly new to C++ and all so far I''ve managed to do is a hello world sample. But I was wanting to know how I''d colour the text, like output it cyan with a red background or somesuch other thing... cheers,

Share this post


Link to post
Share on other sites
Advertisement
DOS Borland compilers used to have cprintf function to do this in conio.h. There is no standard way to print colored text in C++, so there''s no general solution. For Win32, look up "console functions" in MSDN.

Share this post


Link to post
Share on other sites
If your doing something in a console program for Windows, lookup:

SetConsoleTextAttribute()

in MSDN.

If your wanting to output colored text into a Windows window, lookup:

SetTextColor();
TextOut();

in MSDN


This is all assuming you actually have MSDN



It''s all you need

Share this post


Link to post
Share on other sites
Well technically everyone has msdn... http://msdn.microsoft.com

-----------------------
"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else''s drivers, I assume it is their fault" - John Carmack

Share this post


Link to post
Share on other sites
Also, you can always use ANSI escape sequences. Look it up on Google. Here is an example:
std::cout << "\e[31m" << "This text is red." << std::endl;
Or you can use windows functions like the above posters said. Hope this helps.

------------------------------
BASIC programmers don''t die, they just GOSUB and don''t return.

Share this post


Link to post
Share on other sites
www.ansi.com = American National Skyline Industries ;¬)



_________________________________________________________________________
Can someone be nice and help me on my way to be the next Hideo Kojima?
Thought So...

Share this post


Link to post
Share on other sites

  • 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!