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