Ummm... this has been well documented for like 30 years...
Why wouldn't you just include conio.h and use the textcolor() and textbackground() functions?
It's not a standard header but it's included with most Windows compilers.
From the Pelles C helpfile...
Code:
_textcolor, _textbackground functions [not standard C] [4.00]
Purpose:
Sets the text or background color for the console.
Syntax:
void _textcolor(int color);
void _textbackground(int color);
Declared in:
<conio.h>
Description:
The _textcolor function sets the text color, and the _textbackground function sets the background color - to be used by subsequent calls to the _clreol, _clrscr, _cprintf, _cscanf, _cwprintf, _putch and _getche functions. The colors can either be specified as a bitmask where there is one bit each for blue, green, red, and intensity, starting from the lowest bit - or a number from 0 to 15.
If you define _CONIO_RETRO_COLORS before including <conio.h> you can also use the following macros to specify the color:
Macro Value Comment
BLACK 0 -
BLUE 1 BLUE
GREEN 2 GREEN
CYAN 3 BLUE + GREEN
RED 4 RED
MAGENTA 5 BLUE + RED
BROWN 6 GREEN + RED
LIGHTGRAY 7 BLUE + GREEN + RED
DARKGRAY 8 INTENSITY
LIGHTBLUE 9 BLUE + INTENSITY
LIGHTGREEN 10 GREEN + INTENSITY
LIGHTCYAN 11 BLUE + GREEN + INTENSITY
LIGHTRED 12 RED + INTENSITY
LIGHTMAGENTA 13 BLUE + RED + INTENSITY
YELLOW 14 GREEN + RED + INTENSITY
WHITE 15 BLUE + GREEN + RED + INTENSITY
Returns:
Nothing