1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
void textColor( const unsigned int color )
{
HANDLE outHandle = GetStdHandle( STD_OUTPUT_HANDLE );
SetConsoleTextAttribute( outHandle , color );
}
int main( void )
{
enum
{
black , blue , green , cyan , red , magenta , brown , normal , darkgrey , lightblue , lightgreen , lightcyan , lightred , lightmagenta , yellow , white
};
textColor( blue );
std::cout << "Hello world! I am blue!" << std::endl;
textColor( red );
std::cout << "Hello world! I am red!" << std::endl;
textColor( normal );
std::cout << "Hello world! I am normal!" << std::endl;
for(unsigned int i = 0; i < 256; i++)
{
textColor( i );
std::cout << "Color " << i << std::endl;
}
}
|