最佳答案:
textcolor,计算机用语,意思是在文本模式中选择新的字符颜色,但是此函数仅在TurboC编译器中被支持,在其后版本的开发环境中不支持,TurboC之后的IDE需要添加windows.h头文件,使用windows API来代替此函数的功能。
详情介绍
textcolor,计算机用语,意思是在文本模式中选择新的字符颜色,但是此函数仅在TurboC编译器中被支持,在其后版本的开发环境中不支持,TurboC之后的IDE需要添加windows.h头文件,使用windows API来代替此函数的功能。
- 中文名
- textcolor
- 外文名
- textcolor
- 功 能
- 在文本模式中选择新的字符颜色
- 用 法
- void textcolor(int newcolor);
textcolorC语言函数textcolor
函数名: textcolor
功 能: 在文本模式中选择新的字符颜色
用 法: void textcolor(int newcolor);
参数说明:其中参数newcolor为要设置的颜色,它的取值可以是下面的符号常量:
BLACK | BLUE | GREEN | CYAN |
RED | MAGENTA | BROWN | LIGHTGRAY |
DARKGRAY | LIGHTBLUE | LIGHTGREEN | LIGHTCYAN |
LIGHTRED | LIGHTMAGENTA | YELLOW | WHITE |
程序例1:(一个很经典的程序例程)
#include <conio.h>
int main(void)
{
int i, j;
clrscr();
for (i=0; i<9; i++)
{
for (j=0; j<80; j++)
cprintf("C");
cprintf("rn");
textcolor(i+1);
}
return 0;
}
程序例2:
#include <conio.h>
int main(void)
{
int i;
for (i=0; i<15; i++)
{
textcolor(i);
cprintf("Foreground Colorrn");
}
return 0;
}
在VC中的conio.h中无此函数。
textcolorpascal语言类型:uses crt
程序例1:
program yanse;
uses crt;
begin
textcolor(red);
writeln('Baidu hao!!!');
end.
程序例2:
program yanse;
uses crt;
begin
textcolor(4);
writeln('Baidu hao!!!');
end.
{
textcolor()中的数字对应的颜色见下:
Black=0
Blue=1
Green=2
Cyan=3
Red=4
Magenta=5
Brown=6
LightGray=7
DarkGray=8
LightBlue=9
LightGreen=10
LightCyan=11
LightRed=12
LightMagenta=13
Yellow=14
White=15
}
//上述两个程序都将输出红色的“Baidu hao!!! ”
扩展:
program yanse;
uses crt;
begin
textcolor(red);
textbackground(green);
writeln('Baidu hao!!!');
end.
//这个程序将输出红色的“Baidu hao!!! ”,并配有绿色背景


