// 控制台程式的基本文本顔色
// #define FOREGROUND_BLUE 0x0001 // text color contains blue.
// #define FOREGROUND_GREEN 0x0002 // text color contains green.
// #define FOREGROUND_RED 0x0004 // text color contains red.
// #define FOREGROUND_INTENSITY 0x0008 // text color is intensified.
//不同的組合可呈現如下幾種顔色
■ 0x00
■ 0x01
■ 0x02
■ 0x03
■ 0x04
■ 0x05
■ 0x06
■ 0x07
■ 0x08
■ 0x09
■ 0x0a
■ 0x0b
■ 0x0c
■ 0x0d
■ 0x0e
//示例程式
intmain(intargc, char* argv[])
{
HANDLE hConsole=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole,0x0c);//基本顔色的組合
cout<<"紅色文字"<<endl;
return 0;
}
紅色文字