⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fs.htm

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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -