I know how to get output in color with cprintf but not with cout<<; can someone please help? Thanks.
I know how to get output in color with cprintf but not with cout<<; can someone please help? Thanks.
arj
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
Last edited by Arooj; 07-19-2011 at 07:39 AM. Reason: spelling error; more text
arj
Mate, why? There are much better alternatives which are free, that compiler is wildly out of date, please get codeblocks or similar.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
Thought for the day:FLTK: "The most fun you can have with your clothes on.""Are you sure your sanity chip is fully screwed in sir?" (Kryten)
Stroustrup:
"If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"
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.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.