Colored Text

This is a discussion on Colored Text within the A Brief History of Cprogramming.com forums, part of the Community Boards category; How do I put colored text to the screen without using printf()? C++ does not support it. Borland 5.1 answer ...

  1. #1
    A Banana Yoshi's Avatar
    Join Date
    Oct 2001
    Posts
    859

    Colored Text

    How do I put colored text to the screen without using printf()? C++ does not support it.

    Borland 5.1 answer please
    ---------------------------

    Engineer223

    yoshi!
    Last edited by Yoshi; 11-22-2001 at 06:56 PM.
    Yoshi

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    Look up conio.h with a text editor. You'll find several #define statements in the middle of the file defining colors 1-15 (the DOS colors - I'm assuming you're doing DOS programming) with names like #define CYAN 3, etc....
    Most C++ runtime library i/o systems should support this in some way or another, most likely through a function parameter.

    __________________________________________________
    Sean Mackrory
    sean_mackrory@hotmail.com

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Off topic

    Originally posted by Engineer223

    Engineer223

    A.K.A. Arcturus Mengsk, Emperor of the Terran Dominion
    I thought your Dominion was crushed by Kerrigan, so you're only a "former Emperor".
    However, you're the reason she is what she is, so I don't feel sorry for ya . Have a good one...

    the Fenix of Antioch
    (Did someone tell you that I fell in battle? Naah!)
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  4. #4
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    C++ does support it. and the windows version works better than the conio version.


    simple code to output colored text.


    #include <windows.h> // always include this it helps.

    void Gcoloredtext()
    {
    HANDLE hStdout;
    hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
    int G = 128;
    SetConsoleTextAttribute(hStdout, G); // blue bg, white text
    printf("Blue Background with White text");
    int R = 7;
    SetConsoleTextAttribute(hStdout, R); // reset to grey.
    };
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  5. #5
    A Banana Yoshi's Avatar
    Join Date
    Oct 2001
    Posts
    859
    I found it, it was cprintf();

    Thanks for everyone's help
    Yoshi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to use FTP?
    By maxorator in forum C++ Programming
    Replies: 8
    Last Post: 11-04-2005, 03:17 PM
  2. Colored Text in C
    By colorC in forum C Programming
    Replies: 4
    Last Post: 02-23-2004, 04:58 AM
  3. Replies: 1
    Last Post: 07-13-2002, 06:45 PM
  4. how to cout colored text?
    By Guanhui in forum C++ Programming
    Replies: 1
    Last Post: 07-05-2002, 09:14 AM
  5. Ok, Structs, I need help I am not familiar with them
    By incognito in forum C++ Programming
    Replies: 7
    Last Post: 06-29-2002, 10:45 PM

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