windows和Linux都可用的一个类...用来设置颜色,没有太复杂。简单够用吧。
#ifdef _WIN32
#include <Windows.h>
class FontColor
{
public:
FontColor()
{
m_hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
}
void SetColor(int nColor)
{
SetConsoleTextAttribute(m_hStdOut, nColor);
}
void UnSetColor()
{
SetConsoleTextAttribute(m_hStdOut, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}
~FontColor()
{
}
private:
HANDLE m_hStdOut;
};
#else
class FontColor
{
public:
FontColor()
{
m_bUnset = true;
}
void SetColor(int nColor)
{
printf("