textcolor

textcolor,計算機用語,意思是在文本模式中選擇新的字元顏色,但是此函式僅在TurboC編譯器中被支持,在其後版本的開發環境中不支持,TurboC之後的IDE需要添加windows.h頭檔案,使用windows API來代替此函式的功能。

C語言函式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("\r\n");

textcolor(i+1);

}

return 0;

}

程式例2:

#include <conio.h>

int main(void)

{

int i;

for (i=0; i<15; i++)

{

textcolor(i);

cprintf("Foreground Color\r\n");

}

return 0;

}

在VC中的conio.h中無此函式。

pascal語言類型: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!!! ”,並配有綠色背景

相關詞條

相關搜尋

熱門詞條

聯絡我們