1.改变整个控制台的颜色
用 system("color 0A");永远英文
其中color后面的0是背景色代号,A是前景色代号。各颜色代码如下:
0=黑色1=蓝色2=绿色3=湖蓝色
4=红色5=紫色6=黄色7=白色
8=灰色9=淡蓝色A=淡绿色B=淡浅绿色
C=淡红色D=淡紫色E=淡黄色F=亮白色
2.改变下一个输出或者输入字体和背景的颜色
采用SetConsoleTextAttribute函数,如
White on Black:
vae什么意思SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
Red on Black:
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_RED);
Green on Black:
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_GREEN);
Yellow on Black:
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_RED | FOREGROUND_GREEN);
Blue on Black:
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_BLUE);
Magenta on Black:
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_RED | FOREGROUND_BLUE);
Cyan on Black:
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_GREEN | FOREGROUND_BLUE);
Black on Gray:
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY |BACKGROUND_INTENSITY);
extractBlack on White:
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY |FOREGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE);
Red on White:
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY |FOREGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE |FOREGROUND_RED);等等。
需要引入头文件:泰语学习网
windows.h
函数原型:
abdicate
BOOL SetConsoleTextAttribute(HANDLE hConsoleOutput, WORD wAttributes); wAttributes 的取值含义对应如下:
Attribute Meaning
foreground_blue Text color contains blue.
foreground_green Text color contains green.
foreground_red Text color contains red.
foreground_intensity Text color is intensified. background_blue Background color contains blue. background_green Background color contains green. background_red Background color contains red. background_intensity Background color is intensified. common_lvb_leading_byte Leading byte.
common_lvb_trailing_byte Trailing byte.
common_lvb_grid_horizontal Top horizontal.
common_lvb_grid_lvertical Left vertical.
common_lvb_grid_rvertical Right vertical.
common_lvb_rever_video Rever foreground and background
attributes.
common_lvb_underscore Underscore.
发誓的英文#include <stdio.h>
祝老师教师节快乐的英语
#include <windows.h>
int main(void)
{
母亲节英语怎么说SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), BACKGROUND_RED | FOREGROUND_GREEN);
printf("TestA");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), BACKGROUND_BLUE | FOREGROUND_RED | FOREGROUND_GREEN);绝命毒师第三季
printf("TestB");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
美国电视台FOREGROUND_INTENSITY | FOREGROUND_BLUE);
printf("TestC\n");
getchar();
return0;
}