c语言改变颜色

更新时间:2023-05-21 12:16:21 阅读: 评论:0

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;
}

本文发布于:2023-05-21 12:16:21,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/78/719384.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

上一篇:c语言词汇表
下一篇:语法分析代码
标签:代号   蓝色   函数
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图