c语言库函数(编辑修改稿)内容摘要:

(i=0。 i10。 i++) putchar(HORIZ)。 putchar(RIGHT_TOP)。 putchar(39。 \n39。 )。 /* draw the middle */ for (i=0。 i4。 i++) { putchar(VERT)。 for (j=0。 j10。 j++) putchar(39。 39。 )。 putchar(VERT)。 putchar(39。 \n39。 )。 } /* draw the bottom */ putchar(LEFT_BOT)。 for (i=0。 i10。 i++) putchar(HORIZ)。 putchar(RIGHT_BOT)。 putchar(39。 \n39。 )。 return 0。 } 函数名 : putenv 功 能 : 把字符串加到当前环境中 用 法 : int putenv(char *envvar)。 程序例 : include include include include include int main(void) { char *path, *ptr。 int i = 0。 /* get the current path environment */ ptr = getenv(PATH)。 /* set up new path */ path = malloc(strlen(ptr)+15)。 strcpy(path,PATH=)。 strcat(path,ptr)。 strcat(path,。 c:\\temp)。 /* replace the current path and display current environment */ putenv(path)。 while (environ[i]) printf(%s\n,environ[i++])。 return 0。 } 函数名 : putimage 功 能 : 在屏幕上输出一个位图 用 法 : void far putimage(int x, int y, void far *bitmap, int op)。 程序例 : include include include include define ARROW_SIZE 10 void draw_arrow(int x, int y)。 int main(void) { /* request autodetection */ int gdriver = DETECT, gmode, errorcode。 void *arrow。 int x, y, maxx。 unsigned int size。 /* initialize graphics and local variables */ initgraph(amp。 gdriver, amp。 gmode, )。 /* read result of initialization */ errorcode = graphresult()。 if (errorcode != grOk) /* an error occurred */ { printf(Graphics error: %s\n, grapherrormsg(errorcode))。 printf(Press any key to halt:)。 getch()。 exit(1)。 /* terminate with an error code */ } maxx = getmaxx()。 x = 0。 y = getmaxy() / 2。 /* draw the image to be grabbed */ draw_arrow(x, y)。 /* calculate the size of the image */ size = imagesize(x, yARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE)。 /* allocate memory to hold the image */ arrow = malloc(size)。 /* grab the image */ getimage(x, yARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE, arrow)。 /* repeat until a key is pressed */ while (!kbhit()) { /* erase old image */ putimage(x, yARROW_SIZE, arrow, XOR_PUT)。 x += ARROW_SIZE。 if (x = maxx) x = 0。 /* plot new image */ putimage(x, yARROW_SIZE, arrow, XOR_PUT)。 } /* clean up */ free(arrow)。 closegraph()。 return 0。 } void draw_arrow(int x, int y) { /* draw an arrow on the screen */ moveto(x, y)。 linerel(4*ARROW_SIZE, 0)。 linerel(2*ARROW_SIZE, 1*ARROW_SIZE)。 linerel(0, 2*ARROW_SIZE)。 linerel(2*ARROW_SIZE, 1*ARROW_SIZE)。 } 函数名 : putpixel 功 能 : 在指定位置画一像素 用 法 : void far putpixel (int x, int y, int pixelcolor)。 程序例 : include include include include include define PIXEL_COUNT 1000 define DELAY_TIME 100 /* in milliseconds */ int main(void) { /* request autodetection */ int gdriver = DETECT, gmode, errorcode。 int i, x, y, color, maxx, maxy, maxcolor, seed。 /* initialize graphics and local variables */ initgraph(amp。 gdriver, amp。 gmode, )。 /* read result of initialization */ errorcode = graphresult()。 if (errorcode != grOk) /* an error occurred */ { printf(Graphics error: %s\n, grapherrormsg(errorcode))。 printf(Press any key to halt:)。 getch()。 exit(1)。 /* terminate with an error code */ } maxx = getmaxx() + 1。 maxy = getmaxy() + 1。 maxcolor = getmaxcolor() + 1。 while (!kbhit()) { /* seed the random number generator */ seed = random(32767)。 srand(seed)。 for (i=0。 iPIXEL_COUNT。 i++) { x = random(maxx)。 y = random(maxy)。 color = random(maxcolor)。 putpixel(x, y, color)。 } delay(DELAY_TIME)。 srand(seed)。 for (i=0。 iPIXEL_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。 } 函数名 : puts 功 能 : 送一字符串到流中 用 法 : int puts(char *string)。 程序例 : include int main(void) { char string[] = This is an example output string\n。 puts(string)。 return 0。 } 函数名 : puttext 功 能 : 将文本从存储区拷贝到屏幕 用 法 : int puttext(int left, int top, int right, int bottom, void *source)。 程序例 : include int main(void) { char buffer[512]。 /* put some text to the console */ clrscr()。 gotoxy(20, 12)。 cprintf(This is a test. Press any key to continue ...)。 getch()。 /* grab screen contents */ gettext(20, 12, 36, 21,buffer)。 clrscr()。 /* put selected characters back to the screen */ gotoxy(20, 12)。 puttext(20, 12, 36, 21, buffer)。 getch()。 return 0。 } 函数名 : putw 功 能 : 把一字符或字送到流中 用 法 : int putw(int w, FILE *stream)。 程序例 : include include define FNAME test.$$$ int。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。