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

📄 fs.htm

📁 turbo c
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<P>&nbsp;&nbsp; /* Add one to the minutes struct element and then callsettime&nbsp; */<BR>&nbsp;&nbsp; t.ti_min++;<BR>&nbsp;&nbsp; settime(&amp;t);<P>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: setusercharsize<BR>功&nbsp; 能: 为矢量字体改变字符宽度和高度<BR>用&nbsp; 法: void far setusercharsize(int multx, int dirx, int multy,int diry);<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 autodetection */<BR>&nbsp;&nbsp; int gdriver = DETECT, gmode, errorcode;<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;&nbsp;&nbsp;&nbsp;&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);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* terminate with an error code */<BR>&nbsp;&nbsp; }<P>&nbsp;&nbsp; /* select a text style */<BR>&nbsp;&nbsp; settextstyle(TRIPLEX_FONT, HORIZ_DIR, 4);<P>&nbsp;&nbsp; /* move to the text starting position */<BR>&nbsp;&nbsp; moveto(0, getmaxy() / 2);<P>&nbsp;&nbsp; /* output some normal text */<BR>&nbsp;&nbsp; outtext("Norm ");<P>&nbsp;&nbsp; /* make the text 1/3 the normal width */<BR>&nbsp;&nbsp; setusercharsize(1, 3, 1, 1);<BR>&nbsp;&nbsp; outtext("Short ");<P>&nbsp;&nbsp; /* make the text 3 times normal width */<BR>&nbsp;&nbsp; setusercharsize(3, 1, 1, 1);<BR>&nbsp;&nbsp; outtext("Wide");<P>&nbsp;&nbsp; /* clean up */<BR>&nbsp;&nbsp; getch();<BR>&nbsp;&nbsp; closegraph();<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<P>函数名: setvbuf<BR>功&nbsp; 能: 把缓冲区与流相关<BR>用&nbsp; 法: int setvbuf(FILE *stream, char *buf, int type, unsignedsize);<BR>程序例:<P>#include &lt;stdio.h><P>int main(void)<BR>{<BR>&nbsp;&nbsp; FILE *input, *output;<BR>&nbsp;&nbsp; char bufr[512];<P>&nbsp;&nbsp; input = fopen("file.in", "r+b");<BR>&nbsp;&nbsp; output = fopen("file.out", "w");<P>&nbsp;&nbsp; /* set up input stream for minimal disk access,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using our own character buffer */<BR>&nbsp;&nbsp; if (setvbuf(input, bufr, _IOFBF, 512) != 0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("failed to set up buffer forinput file\n");<BR>&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("buffer set up for input file\n");<P>&nbsp;&nbsp; /* set up output stream for line buffering using spacethat<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; will be obtained through an indirectcall to malloc */<BR>&nbsp;&nbsp; if (setvbuf(output, NULL, _IOLBF, 132) != 0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("failed to set up buffer foroutput file\n");<BR>&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("buffer set up for output file\n");<P>&nbsp;&nbsp; /* perform file I/O here */<P>&nbsp;&nbsp; /* close files */<BR>&nbsp;&nbsp; fclose(input);<BR>&nbsp;&nbsp; fclose(output);<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<P>函数名: setvect<BR>功&nbsp; 能: 设置中断矢量入口<BR>用&nbsp; 法: void setvect(int intr_num, void interrupt(*isr)());<BR>程序例:<P>/***NOTE:<BR>&nbsp;&nbsp;&nbsp; This is an interrupt service routine.&nbsp; Youcan NOT compile this<BR>&nbsp;&nbsp;&nbsp; program with Test Stack Overflow turned on and getan executable<BR>&nbsp;&nbsp;&nbsp; file which will operate correctly. */<P>#include &lt;stdio.h><BR>#include &lt;dos.h><BR>#include &lt;conio.h><P>#define INTR 0X1C&nbsp;&nbsp;&nbsp; /* The clock tick interrupt */<P>void interrupt ( *oldhandler)(void);<P>int count=0;<P>void interrupt handler(void)<BR>{<BR>/* increase the global counter */<BR>&nbsp;&nbsp; count++;<P>/* call the old routine */<BR>&nbsp;&nbsp; oldhandler();<BR>}<P>int main(void)<BR>{<BR>/* save the old interrupt vector */<BR>&nbsp;&nbsp; oldhandler = getvect(INTR);<P>/* install the new interrupt handler */<BR>&nbsp;&nbsp; setvect(INTR, handler);<P>/* loop until the counter exceeds 20 */<BR>&nbsp;&nbsp; while (count &lt; 20)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("count is %d\n",count);<P>/* reset the old interrupt handler */<BR>&nbsp;&nbsp; setvect(INTR, oldhandler);<P>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: setverify<BR>功&nbsp; 能: 设置验证状态<BR>用&nbsp; 法: void setverify(int value);<BR>程序例:<P>#include &lt;stdio.h><BR>#include &lt;conio.h><BR>#include &lt;dos.h><P>int main(void)<BR>{<BR>&nbsp;&nbsp; int verify_flag;<P>&nbsp;&nbsp; printf("Enter 0 to set verify flag off\n");<BR>&nbsp;&nbsp; printf("Enter 1 to set verify flag on\n");<P>&nbsp;&nbsp; verify_flag = getch() - 0;<P>&nbsp;&nbsp; setverify(verify_flag);<P>&nbsp;&nbsp; if (getverify())<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("DOS verify flag is on\n");<BR>&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("DOS verify flag is off\n");<P>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: setviewport<BR>功&nbsp; 能: 为图形输出设置当前视口<BR>用&nbsp; 法: void far setviewport(int left, int top, int right,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int bottom, int clipflag);<BR>程序例:<P>#include &lt;graphics.h><BR>#include &lt;stdlib.h><BR>#include &lt;stdio.h><BR>#include &lt;conio.h><P>#define CLIP_ON 1&nbsp;&nbsp; /* activates clipping in viewport */<P>int main(void)<BR>{<BR>&nbsp;&nbsp; /* request auto detection */<BR>&nbsp;&nbsp; int gdriver = DETECT, gmode, errorcode;<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; setcolor(getmaxcolor());<P>&nbsp;&nbsp; /* message in default full-screen viewport */<BR>&nbsp;&nbsp; outtextxy(0, 0, "* &lt;-- (0, 0) in default viewport");<P>&nbsp;&nbsp; /* create a smaller viewport */<BR>&nbsp;&nbsp; setviewport(50, 50, getmaxx()-50, getmaxy()-50, CLIP_ON);<P>&nbsp;&nbsp; /* display some text */<BR>&nbsp;&nbsp; outtextxy(0, 0, "* &lt;-- (0, 0) in smaller viewport");<P>&nbsp;&nbsp; /* clean up */<BR>&nbsp;&nbsp; getch();<BR>&nbsp;&nbsp; closegraph();<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: setvisualpage<BR>功&nbsp; 能: 设置可见图形页号<BR>用&nbsp; 法: void far setvisualpage(int pagenum);<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; /* select a driver and mode that supports */<BR>&nbsp;&nbsp; /* multiple pages.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/<BR>&nbsp;&nbsp; int gdriver = EGA, gmode = EGAHI, errorcode;<BR>&nbsp;&nbsp; int x, y, ht;<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;<BR>&nbsp;&nbsp; ht = textheight("W");<P>&nbsp;&nbsp; /*&nbsp; select the off screen page for drawing */<BR>&nbsp;&nbsp; setactivepage(1);<P>&nbsp;&nbsp; /* draw a line on page #1 */<BR>&nbsp;&nbsp; line(0, 0, getmaxx(), getmaxy());<P>&nbsp;&nbsp; /* output a message on page #1 */<BR>&nbsp;&nbsp; settextjustify(CENTER_TEXT, CENTER_TEXT);<BR>&nbsp;&nbsp; outtextxy(x, y, "This is page #1:");<BR>&nbsp;&nbsp; outtextxy(x, y+ht, "Press any key to halt:");<P>&nbsp;&nbsp; /* select drawing to page #0 */<BR>&nbsp;&nbsp; setactivepage(0);<P>&nbsp;&nbsp; /* output a message&nbsp; on page #0 */<BR>&nbsp;&nbsp; outtextxy(x, y, "This is page #0.");<BR>&nbsp;&nbsp; outtextxy(x, y+ht, "Press any key to view page #1:");<BR>&nbsp;&nbsp; getch();<P>&nbsp;&nbsp; /* select page #1 as the visible page */<BR>&nbsp;&nbsp; setvisualpage(1);<P>&nbsp;&nbsp; /* clean up */<BR>&nbsp;&nbsp; getch();<BR>&nbsp;&nbsp; closegraph();<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: setwritemode<BR>功&nbsp; 能: 设置图形方式下画线的输出模式<BR>用&nbsp; 法: void far setwritemode(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()<BR>{<BR>&nbsp;&nbsp; /* request auto detection */<BR>&nbsp;&nbsp; int gdriver = DETECT, gmode, errorcode;<BR>&nbsp;&nbsp; int xmax, ymax;<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; xmax = getmaxx();<BR>&nbsp;&nbsp; ymax = getmaxy();<P>&nbsp;&nbsp; /* select XOR drawing mode */<BR>&nbsp;&nbsp; setwritemode(XOR_PUT);<P>&nbsp;&nbsp; /* draw a line */<BR>&nbsp;&nbsp; line(0, 0, xmax, ymax);<BR>&nbsp;&nbsp; getch();<P>&nbsp;&nbsp; /* erase the line by drawing over it */<BR>&nbsp;&nbsp; line(0, 0, xmax, ymax);<BR>&nbsp;&nbsp; getch();<P>&nbsp;&nbsp; /* select overwrite drawing mode */<BR>&nbsp;&nbsp; setwritemode(COPY_PUT);<P>&nbsp;&nbsp; /* draw a line */<BR>&nbsp;&nbsp; line(0, 0, xmax, ymax);<P>&nbsp;&nbsp; /* clean up */<BR>&nbsp;&nbsp; getch();<BR>&nbsp;&nbsp; closegraph();<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: signal<BR>功&nbsp; 能: 设置某一信号的对应动作<BR>用&nbsp; 法: int signal(int sig, sigfun fname);<BR>程序例:<P>/* This example installs a signal handler routine for SIGFPE,<BR>&nbsp;&nbsp; catches an integer overflow condition, makes an adjustment<BR>&nbsp;&nbsp; to AX register, and returns. This example program MAYcause<BR>&nbsp;&nbsp; your computer to crash, and will produce runtime errors<BR>&nbsp;&nbsp; depending on which memory model is used.<BR>*/<P>#pragma inline<BR>#include &lt;stdio.h><BR>#include &lt;signal.h><P>void Catcher(int sig, int type, int *reglist)<BR>{<BR>&nbsp;&nbsp; printf("Caught it!\n");<BR>&nbsp;&nbsp; *(reglist + 8) = 3;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* make return AX = 3 */<BR>}<P>int main(void)<BR>{<BR>&nbsp;&nbsp; signal(SIGFPE, Catcher);<BR>&nbsp;&nbsp; asm&nbsp;&nbsp;&nbsp;&nbsp; mov&nbsp;&nbsp;&nbsp;&nbsp;ax,07FFFH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* AX = 32767 */<BR>&nbsp;&nbsp; asm&nbsp;&nbsp;&nbsp;&nbsp; inc&nbsp;&nbsp;&nbsp;&nbsp;ax&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* cause overflow */<BR>&nbsp;&nbsp; asm&nbsp;&nbsp;&nbsp;&nbsp; into&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* activate handler */<P>&nbsp;&nbsp; /* The handler set AX to 3 on return. If that hadn't happened,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; there would have been another exceptionwhen the next 'into'<BR>&nbsp;&nbsp;&nbsp;&n

⌨️ 快捷键说明

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