Thread: Text Color?

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    59

    Text Color?

    Is it possible to set text colors in c, and if so how can I do it?

    -Thanks Much-

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    There is no ANSI standard to display colored text. This is implementation specific and will be different based on your compiler and operating system combination.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Unregistered
    Guest
    #include <conio.h> /*Contains text colors */

    main()
    {
    textcolor( BLUE ); /*change text color to blue */
    cprintf("Hello World"); /*Will print out Hello world in blue*/
    textbackground( GREEN ); /*background color is green*/
    textcolor( RED ); /*change text to red*/
    cprintf("\nHello Again");/*Will have a background green and color of red*/
    }

    Edit the header file conio.h to see what colors you can choose.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Code:
    main() 
    { 
      textcolor( BLUE ); /*change text color to blue */ 
      cprintf("Hello World"); /*Will print out Hello world in blue*/ 
      textbackground( GREEN ); /*background color is green*/ 
      textcolor( RED ); /*change text to red*/ 
      cprintf("\nHello Again");/*Will have a background green and color of red*/ 
    }
    At least you didn't use void main, but all of those functions are nonstandard and I have yet to see a non-Borland compiler have textcolor or textbackground. Believe me when I say that nonstandard should be avoided when possible and used only when necessary.

    -Prelude
    My best code is written with the delete key.

  5. #5
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669
    Is there any function in VC++ 6.0 (on Win98) for changing text color?
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  6. #6
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    Posts
    522

    color in msvc

    Oh boy, there must be hundreds of threads about this, probably thousands.
    I posted some code the other day, HERE
    All spelling mistakes, syntatical errors and stupid comments are intentional.

  7. #7
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669
    Sorry for the stupid question and thank you for your answer.
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GUI Text Color Problem
    By justlivelife15 in forum Windows Programming
    Replies: 3
    Last Post: 06-25-2007, 05:47 AM
  2. Change text color in C
    By IndioDoido in forum C Programming
    Replies: 9
    Last Post: 04-15-2007, 05:54 AM
  3. Critique my lighting model.
    By psychopath in forum Game Programming
    Replies: 4
    Last Post: 08-12-2006, 06:23 PM
  4. Color text from windows.h?
    By Saintdog in forum C++ Programming
    Replies: 10
    Last Post: 12-03-2004, 09:20 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