Thread: different colors

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    19

    Question different colors

    I was wondering if anybody knew what other colors you could use in DOS.

    So far I know of the colors blue, green, and red, but when I enter some other colors I get an error.

  2. #2
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743
    It depends what mode you are using.

    if you are in a normal text mode, you have 16 color choices. you can find them in either dos.h, conio.h, or graphics.h. (cant remember which). if you are in a graphics mode, it depends what mode you are in. 13h has 256 24-bit colors, 112h is 16 million, etc.
    My Website

    "Circular logic is good because it is."

  3. #3
    A Banana Yoshi's Avatar
    Join Date
    Oct 2001
    Posts
    859
    if you are in a normal text mode, you have 16 color choices. you can find them in either dos.h, conio.h, or graphics.h. (cant remember which).

    conio.h it is
    Yoshi

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    1

    sexcelent

    how do you actually use them?

  5. #5
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    You use them by calling settextcolor(). There are other functions in C that allow you to change colors as well. Look in the conio.h header file for more info or your help file.

  6. #6
    A Banana Yoshi's Avatar
    Join Date
    Oct 2001
    Posts
    859
    textcolor(COLOR or corresponding number) = set text color
    textbackground(COLOR or corresponding number) = ground of input.

    you have to use cprintf() to use it, though. But, no big deal.
    Yoshi

  7. #7
    Registered User
    Join Date
    Oct 2001
    Posts
    43

    Question

    When I use the textcolor(); cprintf(); fuctions it messes my program all up because the text does not stay to the left. any way i can fix it?

    /*********************************************/
    #include <stdio.h>
    #include <conio.h>

    main()
    {
    textcolor(RED);
    cprintf("this is left\n\n");
    textcolor(LIGHTGRAY);
    cprintf("back to same color);
    return 0;
    }
    /********************************************/

    its does this.
    --------------------------------------------------------------------------
    this is left <----RED

    .......................back to same color <-----not left where i want it
    ()(ôô)()© MonKey ware
    Kyle J. R.

  8. #8
    Unregistered
    Guest

    Smile

    Hi Goof Program
    you are missing " at the end of you last cprintf statment

    sall

  9. #9
    Registered User
    Join Date
    Aug 2001
    Posts
    380
    try replacing this
    cprintf("back to same color);
    with this:
    cprintf("back to same color\n\r");

    correction. it should look like this cprintf("this is left\n\n\r");
    Last edited by lambs4; 12-26-2001 at 07:34 AM.

  10. #10
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Generally there are 16. Look up conio.h and there are #define s for each color, numbered 0-15. This is the only C Runtime library I know of that comes with Borland compilers that has colored-text methods, but I could be wrong.

  11. #11
    Registered User
    Join Date
    Aug 2001
    Location
    CCA
    Posts
    9

    What about Visual C

    // This doesn't compile for me in Visual C.

    #include <stdlib.h>
    #include <stdio.h>
    #include <time.h>
    #include <conio.h>


    int main()
    {
    textcolor(RED);
    cprintf("this is left\n\n");
    textcolor(LIGHTGRAY);
    cprintf("back to same color");
    return 0;
    }

  12. #12
    A Banana Yoshi's Avatar
    Join Date
    Oct 2001
    Posts
    859
    #include<iostream.h>

    cout << endl;

    //remember this?

    cprintf() does end a line but it will continue at where it left off.
    Yoshi

  13. #13
    Registered User
    Join Date
    Aug 2001
    Location
    CCA
    Posts
    9
    Still get three errors, even with the #include <iostream.h> statement in the file. It doesn't like the textcolor() statement, along with the Color references. What gives?


    c:\development\cpp\graphics\graphtest.cpp(10) : error C2065: 'textcolor' : undeclared identifier
    c:\development\cpp\graphics\graphtest.cpp(10) : error C2065: 'RED' : undeclared identifier
    c:\development\cpp\graphics\graphtest.cpp(12) : error C2065: 'LIGHTGRAY' : undeclared identifier
    Error executing cl.exe.

    graphtest.exe - 3 error(s), 0 warning(s)

  14. #14
    Registered User dune911's Avatar
    Join Date
    Sep 2001
    Posts
    140
    well... the textcolor(); function works only with borland compilers

  15. #15
    Registered User datainjector's Avatar
    Join Date
    Mar 2002
    Posts
    356

    you can use conio.h

    U can use coni.h on dev c++ and other compilers check my post on Game programming

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why I only get 8 colors out of ncurses?
    By Nazgulled in forum C Programming
    Replies: 3
    Last Post: 05-08-2007, 06:06 PM
  2. Relation between material colors and light colors.
    By indigo0086 in forum Game Programming
    Replies: 3
    Last Post: 04-18-2007, 03:20 PM
  3. colors in forefox and colors in IE
    By MisterSako in forum Tech Board
    Replies: 3
    Last Post: 05-15-2006, 01:59 PM
  4. colors?
    By planet_abhi in forum Game Programming
    Replies: 1
    Last Post: 09-10-2003, 05:37 PM
  5. Text Colors
    By GaPe in forum C Programming
    Replies: 1
    Last Post: 07-11-2002, 06:57 AM