在VC++中,可以使用textbackground()函数来设置字符的背景颜色。
该函数的原型为:
void textbackground(int color);
其中,color参数表示需要设置的背景颜色,可以是以下常量之一:
例如,下面的代码可以将控制台中输出的字符的背景颜色设置为红色:
#include <conio.h> int main() { textbackground(RED); cprintf("Hello, world!"); getch(); return 0; }
运行此程序后,控制台中输出的字符的背景颜色将会变成红色。