textbackground() 函数在 conio.h 头文件中定义。此函数有助于更改打印文本的背景颜色。
void textbackground(int color); #Where color is a integer variable
textbackground() 函数接受一个参数“color”,它是一个整数变量,用于保存给定颜色的相应整数值。
| 参数 | 描述 | 必需/可选 |
|---|---|---|
| 颜色 | 它有一个整数值 | 必需 |
textbackground() 函数不返回任何值,它只更改文本背景。
#include <stdio.h>
#include <conio.h>
int main()
{
// setting the background color of text
textbackground(GREEN);
cprintf("Change the text background colour to green");
getch();
return 0;
}
输出
Change the text background colour to green /* with green background colour */
#include <stdio.h>
#include <conio.h>
int main()
{
textbackground(RED);
cprintf("and the answer is 42 with a red background.");
getch();
return 0;
}
输出
and the answer is 42 with a red background