Thread: Colored Text

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

    Colored Text

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

    Borland 5.1 answer please


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

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    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

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001

    Off topic

    Originally posted by 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!)

    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
    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.
    (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
    I found it, it was cprintf();

    Thanks for everyone's help

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, 05:45 PM
  4. how to cout colored text?
    By Guanhui in forum C++ Programming
    Replies: 1
    Last Post: 07-05-2002, 08: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, 09:45 PM