1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#include<iostream>
#include<windows.h>
enum COLOR
{
black , blue , green , cyan , red , magenta , brown , normal , darkgrey , lightblue , lightgreen , lightcyan , lightred , lightmagenta , yellow , white
};
std::ostream& operator<<( std::ostream &stm , const COLOR &c)
{
HANDLE out_handle = GetStdHandle( STD_OUTPUT_HANDLE );
SetConsoleTextAttribute( out_handle , c );
return( stm );
}
int main()
{
std::cout << red << "apple\n" << yellow << "banana" << normal << std::endl;
}
|