📄 fs.htm
字号:
<BR> midy = getmaxy() / 2;
<P> settextjustify(CENTER_TEXT, CENTER_TEXT);
<P> /* loop through the available text styles */
<BR> for (style=DEFAULT_FONT; style<=GOTHIC_FONT; style++)
<BR> {
<BR> cleardevice();
<BR> if (style == TRIPLEX_FONT)
<BR> size = 4;
<P> /* select the text style */
<BR> settextstyle(style, HORIZ_DIR, size);
<P> /* output a message */
<BR> outtextxy(midx, midy, fname[style]);
<BR> getch();
<BR> }
<P> /* clean up */
<BR> closegraph();
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函数名: settime
<BR>功 能: 设置系统时间
<BR>用 法: void settime(struct time *timep);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <dos.h>
<P>int main(void)
<BR>{
<BR> struct time t;
<P> gettime(&t);
<BR> printf("The current minute is: %d\n", t.ti_min);
<BR> printf("The current hour is: %d\n", t.ti_hour);
<BR> printf("The current hundredth of a second is: %d\n", t.ti_hund);
<BR> printf("The current second is: %d\n", t.ti_sec);
<P> /* Add one to the minutes struct element and then call
settime */
<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, unsigned
size);
<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 for
input file\n");
<BR> else
<BR> printf("buffer set up for input file\n");
<P> /* set up output stream for line buffering using space
that
<BR> will be obtained through an indirect
call to malloc */
<BR> if (setvbuf(output, NULL, _IOLBF, 132) != 0)
<BR> printf("failed to set up buffer for
output 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. You
can NOT compile this
<BR> program with Test Stack Overflow turned on and get
an 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 error
code */
<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 error
code */
<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 error
code */
<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 dra
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -