How do I get output in color with cout << ?

This is a discussion on How do I get output in color with cout << ? within the C++ Programming forums, part of the General Programming Boards category; I know how to get output in color with cprintf but not with cout<<; can someone please help? Thanks....

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    15

    How do I get output in color with cout << ?

    I know how to get output in color with cprintf but not with cout<<; can someone please help? Thanks.
    arj

  2. #2
    Registered User
    Join Date
    Jul 2008
    Posts
    35
    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.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    15
    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

  4. #4
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,409
    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.

    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:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    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'"

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No output- std::cout
    By Rico Steele in forum C++ Programming
    Replies: 4
    Last Post: 07-12-2010, 07:46 PM
  2. changing cout output
    By Yohumbus in forum C++ Programming
    Replies: 1
    Last Post: 10-23-2002, 04:09 AM
  3. color cout..
    By aboulchouch in forum C++ Programming
    Replies: 4
    Last Post: 06-05-2002, 07:46 AM
  4. Changing printf/cout's color in the command box?
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 01-12-2002, 06:50 PM
  5. need help with cout & output
    By Shy_girl_311 in forum C++ Programming
    Replies: 5
    Last Post: 12-03-2001, 01:59 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21