#include "stdafx.h"
#include <Windows.h>
#include
<iostream>
using namespace std;
void SetColor(unsigned short
ForeColor=3,unsigned short BackGroundColor=0)
{
HANDLE hCon =
GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hCon,ForeColor|BackGroundColor);
}
int _tmain(int argc, LPTSTR
argv[])
{
SetColor();
std::cout<<"Hello
world!"<<endl;
SetColor(40,30);
std::cout<<"Hello
world!"<<endl;
std::cout<<"Hello
world!"<<endl;
system("pause");
return 0;
}
原文:http://www.cnblogs.com/duyy/p/3603885.html