📄 fs.htm
字号:
<BR> }<P> maxx = getmaxx();<BR> maxy = getmaxy();<BR> setcolor(getmaxcolor());<P> /* select a user defined fill pattern */<BR> setfillpattern(pattern, getmaxcolor());<P> /* fill the screen with the pattern */<BR> bar(0, 0, maxx, maxy);<P> /* clean up */<BR> getch();<BR> closegraph();<BR> return 0;<BR>}<BR> <BR> <P>函数名: setfillstyle<BR>功 能: 设置填充模式和颜色<BR>用 法: void far setfillstyle(int pattern, int color);<BR>程序例:<P>#include <graphics.h><BR>#include <stdlib.h><BR>#include <string.h><BR>#include <stdio.h><BR>#include <conio.h><P>/* the names of the fill styles supported */<BR>char *fname[] = { "EMPTY_FILL",<BR> "SOLID_FILL",<BR> "LINE_FILL",<BR> "LTSLASH_FILL",<BR> "SLASH_FILL",<BR> "BKSLASH_FILL",<BR> "LTBKSLASH_FILL",<BR> "HATCH_FILL",<BR> "XHATCH_FILL",<BR> "INTERLEAVE_FILL",<BR> "WIDE_DOT_FILL",<BR> "CLOSE_DOT_FILL",<BR> "USER_FILL"<BR> };<P>int main(void)<BR>{<BR> /* request auto detection */<BR> int gdriver = DETECT, gmode, errorcode;<BR> int style, midx, midy;<BR> char stylestr[40];<P> /* initialize graphics and local variables */<BR> initgraph(&gdriver, &gmode, "");<P> /* read result of initialization */<BR> errorcode = graphresult();<BR> if (errorcode != grOk) /* an error occurred */<BR> {<BR> printf("Graphics error: %s\n", grapherrormsg(errorcode));<BR> printf("Press any key to halt:");<BR> getch();<BR> exit(1); /* terminate with an errorcode */<BR> }<P> midx = getmaxx() / 2;<BR> midy = getmaxy() / 2;<P> for (style = EMPTY_FILL; style < USER_FILL; style++)<BR> {<BR> /* select the fill style */<BR> setfillstyle(style, getmaxcolor());<P> /* convert style into a string */<BR> strcpy(stylestr, fname[style]);<P> /* fill a bar */<BR> bar3d(0, 0, midx-10, midy, 0, 0);<P> /* output a message */<BR> outtextxy(midx, midy, stylestr);<P> /* wait for a key */<BR> getch();<BR> cleardevice();<BR> }<P> /* clean up */<BR> getch();<BR> closegraph();<BR> return 0;<BR>}<BR> <BR> <P>函数名: setftime<BR>功 能: 设置文件日期和时间<BR>用 法: int setftime(int handle, struct ftime *ftimep);<BR>程序例:<P>#include <stdio.h><BR>#include <process.h><BR>#include <fcntl.h><BR>#include <io.h><P>int main(void)<BR>{<BR> struct ftime filet;<BR> FILE *fp;<P> if ((fp = fopen("TEST.$$$", "w")) == NULL)<BR> {<BR> perror("Error:");<BR> exit(1);<BR> }<P> fprintf(fp, "testing...\n");<P> /* load ftime structure with new time and date */<BR> filet.ft_tsec = 1;<BR> filet.ft_min = 1;<BR> filet.ft_hour = 1;<BR> filet.ft_day = 1;<BR> filet.ft_month = 1;<BR> filet.ft_year = 21;<P> /* show current directory for time and date */<BR> system("dir TEST.$$$");<P> /* change the time and date stamp*/<BR> setftime(fileno(fp), &filet);<P> /* close and remove the temporary file */<BR> fclose(fp);<P> system("dir TEST.$$$");<P> unlink("TEST.$$$");<BR> return 0;<BR>}<BR> <BR> <P>函数名: setgraphbufsize<BR>功 能: 改变内部图形缓冲区的大小<BR>用 法: unsigned far setgraphbufsize(unsigned bufsize);<BR>程序例:<P>#include <graphics.h><BR>#include <stdlib.h><BR>#include <stdio.h><BR>#include <conio.h><P>#define BUFSIZE 1000 /* internal graphics buffer size */<P>int main(void)<BR>{<BR> /* request auto detection */<BR> int gdriver = DETECT, gmode, errorcode;<BR> int x, y, oldsize;<BR> char msg[80];<P> /* set the size of the internal graphics buffer */<BR> /* before making a call to initgraph. */<BR> oldsize = setgraphbufsize(BUFSIZE);<P> /* initialize graphics and local variables */<BR> initgraph(&gdriver, &gmode, "");<P> /* read result of initialization */<BR> errorcode = graphresult();<BR> if (errorcode != grOk) /* an error occurred */<BR> {<BR> printf("Graphics error: %s\n", grapherrormsg(errorcode));<BR> printf("Press any key to halt:");<BR> getch();<BR> exit(1); /* terminate with an errorcode */<BR> }<P> x = getmaxx() / 2;<BR> y = getmaxy() / 2;<P> /* output some messages */<BR> sprintf(msg, "Graphics buffer size: %d", BUFSIZE);<BR> settextjustify(CENTER_TEXT, CENTER_TEXT);<BR> outtextxy(x, y, msg);<BR> sprintf(msg, "Old graphics buffer size: %d", oldsize);<BR> outtextxy(x, y+textheight("W"), msg);<P> /* clean up */<BR> getch();<BR> closegraph();<BR> return 0;<BR>}<BR> <BR> <BR> <P>函数名: setgraphmode<BR>功 能: 将系统设置成图形模式且清屏<BR>用 法: void far setgraphmode(int mode);<BR>程序例:<P>#include <graphics.h><BR>#include <stdlib.h><BR>#include <stdio.h><BR>#include <conio.h><P>int main(void)<BR>{<BR> /* request auto detection */<BR> int gdriver = DETECT, gmode, errorcode;<BR> int x, y;<P> /* initialize graphics and local variables */<BR> initgraph(&gdriver, &gmode, "");<P> /* read result of initialization */<BR> errorcode = graphresult();<BR> if (errorcode != grOk) /* an error occurred */<BR> {<BR> printf("Graphics error: %s\n", grapherrormsg(errorcode));<BR> printf("Press any key to halt:");<BR> getch();<BR> exit(1); /* terminate with an errorcode */<BR> }<P> x = getmaxx() / 2;<BR> y = getmaxy() / 2;<P> /* output a message */<BR> settextjustify(CENTER_TEXT, CENTER_TEXT);<BR> outtextxy(x, y, "Press any key to exit graphics:");<BR> getch();<P> /* restore system to text mode */<BR> restorecrtmode();<BR> printf("We're now in text mode.\n");<BR> printf("Press any key to return to graphics mode:");<BR> getch();<P> /* return to graphics mode */<BR> setgraphmode(getgraphmode());<P> /* output a message */<BR> settextjustify(CENTER_TEXT, CENTER_TEXT);<BR> outtextxy(x, y, "We're back in graphics mode.");<BR> outtextxy(x, y+textheight("W"), "Press any key to halt:");<P> /* clean up */<BR> getch();<BR> closegraph();<BR> return 0;<BR>}<BR> <BR> <BR> <P>函数名: setjmp<BR>功 能: 非局部转移<BR>用 法: int setjmp(jmp_buf env);<BR>程序例:<P>#include <stdio.h><BR>#include <process.h><BR>#include <setjmp.h><P>void subroutine(void);<P>jmp_buf jumper;<P>int main(void)<BR>{<BR> int value;<P> value = setjmp(jumper);<BR> if (value != 0)<BR> {<BR> printf("Longjmp with value %d\n", value);<BR> exit(value);<BR> }<BR> printf("About to call subroutine ... \n");<BR> subroutine();<BR> return 0;<BR>}<P>void subroutine(void)<BR>{<BR> longjmp(jumper,1);<BR>}<BR> <BR> <P>函数名: setlinestyle<BR>功 能: 设置当前画线宽度和类型<BR>用 法: void far setlinestyle(int linestype, unsigned upattern);<BR>程序例:<P>#include <graphics.h><BR>#include <stdlib.h><BR>#include <string.h><BR>#include <stdio.h><BR>#include <conio.h><P>/* the names of the line styles supported */<BR>char *lname[] = {<BR> "SOLID_LINE",<BR> "DOTTED_LINE",<BR> "CENTER_LINE",<BR> "DASHED_LINE",<BR> "USERBIT_LINE"<BR> };<P>int main(void)<BR>{<BR> /* request auto detection */<BR> int gdriver = DETECT, gmode, errorcode;<P> int style, midx, midy, userpat;<BR> char stylestr[40];<P> /* initialize graphics and local variables */<BR> initgraph(&gdriver, &gmode, "");<P> /* read result of initialization */<BR> errorcode = graphresult();<BR> if (errorcode != grOk) /* an error occurred */<BR> {<BR> printf("Graphics error: %s\n", grapherrormsg(errorcode));<BR> printf("Press any key to halt:");<BR> getch();<BR> exit(1); /* terminate with an errorcode */<BR> }<P> midx = getmaxx() / 2;<BR> midy = getmaxy() / 2;<P> /* a user defined line pattern */<BR> /* binary: "0000000000000001" */<BR> userpat = 1;<P> for (style=SOLID_LINE; style<=USERBIT_LINE; style++)<BR> {<BR> /* select the line style */<BR> setlinestyle(style, userpat, 1);<P> /* convert style into a string */<BR> strcpy(stylestr, lname[style]);<P> /* draw a line */<BR> line(0, 0, midx-10, midy);<P> /* draw a rectangle */<BR> rectangle(0, 0, getmaxx(), getmaxy());<P> /* output a message */<BR> outtextxy(midx, midy, stylestr);<P> /* wait for a key */<BR> getch();<BR> cleardevice();<BR> }<P> /* clean up */<BR> closegraph();<BR> return 0;<BR>}<BR> <BR> <BR> <P>函数名: setmem<BR>功 能: 存值到存储区<BR>用 法: void setmem(void *addr, int len, char value);<BR>程序例:<P>#include <stdio.h><BR>#include <alloc.h><BR>#include <mem.h><P>int main(void)<BR>{<BR> char *dest;<P> dest = calloc(21, sizeof(char));<BR> setmem(dest, 20, 'c');<BR> printf("%s\n", dest);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -