# colors in c language...



## tweety_bird_bunny (Jul 26, 2006)

plz tell me how can i change the background and forefround colors using c language im my programs.....
like if i want that the program dat i made on running shud display red color of text and green color in background....

is it possible....wat r the colors available and how to do it.....


----------



## Desmond (Jul 26, 2006)

It is quite possible to do so in your programs. It can be done using the textcolor() and textbackground() functions. Put the integer value of the color between the brackets.

Both these functions can be found in "conio.h"


----------



## nithinks (Jul 26, 2006)

you can also insert blinking texts and backgrounds by the functions provided
in "graphics.h" header.... more info with example programs will be available in the HELP of turbo c editor.


----------



## tuxfan (Jul 27, 2006)

Are you doing this in GUI or older text based DOS type 25x80 interface?

If its the old type interface, I have all the *functions* and *header files* ready for the purpose  You have to straight away #include them and start using.  I have made those files many years ago  so all copy_left_, free for use.

Example, colour.h:

```
/**************************
*
*   Foreground Colours
*
***************************/

#define BLACK       0
#define BLUE        1
#define GREEN       2
#define CYAN        3
#define RED         4
#define MAGNETA     5
#define BROWN       6
#define WHITE       7
#define GRAY        8
#define YELLOW     14  /*   Yellow, same as BRIGHT + BROWN    */

/*************************************************
*
*    To display in Blinking mode     add   BLINK
*    To display Brighter Characters  add   BRIGHT
*
*    e.g.  RED + BLINK
*          RED + BRIGHT + BLINK
*
*    Only foreground can be BRIGHT or BLINKing
*
***************************************************/

#define BRIGHT      8
#define BLINK     128


/*************************************************
*
*   Backgroud Colours
*
*   To display in a particular backgroud colour,
*   add it to foregroud colour
*
*   e.g.   RED + BACK_GREEN
*
**************************************************/

#define BACK_BLACK        0
#define BACK_BLUE        16
#define BACK_GREEN       32
#define BACK_CYAN        48
#define BACK_RED         64
#define BACK_MAGNETA     80
#define BACK_BROWN       96
#define BACK_WHITE      112

```


----------

