-物联网校企联盟技术部
eclipse中我设置的背景是黑色的,写编码过程辩搏纯中颜色就很漂亮而且背景色护眼。
颜色代表的含义:
红色字体 一般是java语法的关键字
灰色字体 一般携咐是银仔注释
……
如果是C/C++程序的话://
首先引入逗迹冲山歼头文件
ConsoleColor.h
或
Windows.h
然后在想改变输出文字颜色的地方加以下语句:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0x0B)
然后用正常州闷的输出语句输出自己的内容即可。但是每改变一次颜色就要调用一下这个函数。
例子:
White
on
Black:
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)
Black
on
White:
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY
|
FOREGROUND_INTENSITY
|
BACKGROUND_RED
|
ACKGROUND_GREEN
|
BACKGROUND_BLUE)
Red
on
White:
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY
|
FOREGROUND_INTENSITY
|
BACKGROUND_RED
|
BACKGROUND_GREEN
|
BACKGROUND_BLUE
|
FOREGROUND_RED)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)