#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
enum Color
{
black,blue,green,lakeBlue,red,purple,yellow,white,gray,
lightBlue,lightGreen,lightSimpleGreen,lightRed,lightPurple,
lightYellow,brightWhite
};
void setColor(enum Color x)
{
if(x>=0 && x<=15)//参数在0-15的范围颜色
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), x); //只有一个参数,改变字体颜色
else//默认的颜色白色
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
}
void setTexColor(char * str,enum Color c){
setColor(c);
printf("%s\n", str);
setColor(white);
}
int main(){
setTexColor("Text test..",green);
return 0;
}