I know how to get output in color with cprintf but not with cout<<; can someone please help? Thanks.
Printable View
I know how to get output in color with cprintf but not with cout<<; can someone please help? Thanks.
That is entirely implementation defined. Tell us more about what operating system you are using, and if you know what it means, what kind of terminal emulator.
Hi Florian, thanks. I am using WindowsXP on a P4. Not sure what you mean by terminal emulator; I use a VGA set at 1024x768; don't believe that's what you were asking. I do programming for my own personal needs; sometimes I'd like to have a few things outputted in a given color which makes it easier to spot them on the screen. Also, the compiler I use is Turbo C++ Ver 3.0 by Borland (1990, 1992). Thanks
Mate, why? There are much better alternatives which are free, that compiler is wildly out of date, please get codeblocks or similar.Quote:
Also, the compiler I use is Turbo C++ Ver 3.0 by Borland (1990, 1992). Thanks
But if you are using that and will not change then if your system will run it there are header files in that borland which will change your text colours. But it is really wasted effort to learn to code using features that are obselete.
Check the faq pages 'how do i' for advice on outputting coloured text in a modern environment
Well if you're stuck with such an old compiler, then you're also stuck with using cprintf as well.
No matter which OS/Compiler you had, getting colour on a console would involve using something specific to your platform (there is no colour in standard C++).
I suppose you could hide the detail inside a suitable class, such that you could do things like
ccout << red << "hello world";
where ccout is your "console" (or colour) output stream, with some extra features, which ultimately ends up calling cprintf() behind the scenes.