|
Turbo C 2.0、Borland C++库函数及用例(50) { x = random(maxx); y = random(maxy); color = random(maxcolor); putpixel(x, y, color); } delay(DELAY_TIME); srand(seed); for (i=0; i<PIXEL_COUNT; i++) { x = random(maxx); y = random(maxy); color = random(maxcolor); if (color == getpixel(x, y)) putpixel(x, y, 0); } } /* clean up */ getch(); closegraph(); return 0; } 函数名: gets 功 能: 从流中取一字符串 用 法: char *gets(char *string); 程序例:#include <stdio.h>int main(void) { char string[80]; printf("Input a string:"); gets(string); printf("The string input was: %s\n", string); return 0; } 函数名: gettext 功 能: 将文本方式屏幕上的文本拷贝到存储区 用 法: int gettext( int left, int top, int right, int bottom, void *destin ); 程序例:#include <conio.h>char buffer[4096];int main(void) { int i; clrscr(); for (i = 0; i <= 20; i++) cprintf("Line #%d\r\n", i); gettext(1, 1, 80, 25, buffer); gotoxy(1, 25); cprintf("Press any key to clear screen..."); getch(); clrscr(); gotoxy(1, 25); cprintf("Press any key to restore screen..."); getch(); puttext(1, 1, 80, 25, buffer); gotoxy(1, 25); cprintf("Press any key to quit..."); getch(); return 0; } 函数名: gettextinfo 功 能: 取得文本模式的显示信息 用 法: void gettextinfo(struct text_info *inforec); 程序例:#include <conio.h>int main(void) { struct text_info ti; gettextinfo(&ti); cprintf("window left %2d\r\n",ti.winleft); cprintf("window top %2d\r\n",ti.wintop); cprintf("window right %2d\r\n",ti.winright); cprintf("window bottom %2d\r\n",ti.winbottom); cprintf("attribute %2d\r\n",ti.attribute); cprintf("normal attribute %2d\r\n",ti.normattr); cprintf("current mode %2d\r\n",ti.currmode); cprintf("screen height %2d\r\n",ti.screenheight); cprintf("screen width %2d\r\n",ti.screenwidth); cprintf("current x %2d\r\n",ti.curx); cprintf("current y %2d\r\n",ti.cury); return 0; } 函数名: gettextsettings 功 能: 返回有关当前图形文本字体的信息
|