I am taking a comp. prog. class that teaches C++ at my high school. I am basically ahead of almost all the class in everything. so i do all the extra credit. one of them is to get color (besides black/white) into other colors. and I would like to make it so that only things i want are colored certain colors. like one of our programs is "ghetto dice"..i would like the dice to be white with the black dots on them. I have the program done so all i need now is colors. which would also goin into most every program i do that it would look good in from now on.
this is the only code ive found that works...
CODE
#include <stdio.h>
#include <windows.h>
void ChangeColour(WORD theColour)
{
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); // Get handle to standard output
SetConsoleTextAttribute(hConsole,theColour); // set the text attribute of the previous handle
}
int main()
{
ChangeColour(FOREGROUND_BLUE); // Set the foreground colour to be blue
printf("This text is blue\n");
ChangeColour(FOREGROUND_RED); // Set the foreground colour to be blue
printf("This text is red\n");
ChangeColour( FOREGROUND_BLUE | BACKGROUND_RED); // Set the foreground colour to be blue, the background to be red
printf("This is blue text on a red background\n");
return 0;
}