Hello world coloured text output?
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,
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.
---visit #directxdev on afternet <- not just for directx, despite the name
[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]
[edited by - Michalson on June 3, 2002 2:27:22 PM]
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
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
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
-----------------------
"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
-----------------------"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
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.
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.
------------------------------BASIC programmers don't die, they just GOSUB and don't return.
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]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
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...
_________________________________________________________________________
Can someone be nice and help me on my way to be the next Hideo Kojima? Thought So...
i get it File: ansi.com
_________________________________________________________________________
Can someone be nice and help me on my way to be the next Hideo Kojima? Thought So...
_________________________________________________________________________
Can someone be nice and help me on my way to be the next Hideo Kojima? Thought So...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement