• Advertisement

Archived

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

Hello world coloured text output?

This topic is 5708 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
[Read my forum policy and don't post vulger non-constructive garbage in this forum again]

[edited by - Michalson on June 3, 2002 2:27:22 PM]

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
quote:
Original post by Pipo DeClown
That aint red....



WinMe/XP/2k ... do not support ANSI escapes anymore

Though I read you can get "ansi.com" to make it work again.


Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]


[edited by - Fruny on June 4, 2002 12:49:23 PM]

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
i get it File: ansi.com

_________________________________________________________________________
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