📄 s3.htm
字号:
<td align=center><table border="0" width="700" cellspacing="0" cellpadding="0" align=center><tr><td valign=top><font color=#cccccc>函数名: setjmp
<br>功 能: 非局部转移
<br>用 法: int setjmp(jmp_buf env);
<br>程序例:
<br>
<br>#include <stdio.h>
<br>#include <process.h>
<br>#include <setjmp.h>
<br>
<br>void subroutine(void);
<br>
<br>jmp_buf jumper;
<br>
<br>int main(void)
<br>{
<br> int value;
<br>
<br> 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>}
<br>
<br>void subroutine(void)
<br>{
<br> longjmp(jumper,1);
<br>}
<br>
<br>
<br>
<br>函数名: setlinestyle
<br>功 能: 设置当前画线宽度和类型
<br>用 法: void far setlinestyle(int linestype, unsigned upattern);
<br>程序例:
<br>
<br>#include <graphics.h>
<br>#include <stdlib.h>
<br>#include <string.h>
<br>#include <stdio.h>
<br>#include <conio.h>
<br>
<br>/* 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> };
<br>
<br>int main(void)
<br>{
<br> /* request auto detection */
<br> int gdriver = DETECT, gmode, errorcode;
<br>
<br> int style, midx, midy, userpat;
<br> char stylestr[40];
<br>
<br> /* initialize graphics and local variables */
<br> initgraph(&gdriver, &gmode, "");
<br>
<br> /* 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> }
<br>
<br> midx = getmaxx() / 2;
<br> midy = getmaxy() / 2;
<br>
<br> /* a user defined line pattern */
<br> /* binary: "0000000000000001" */
<br> userpat = 1;
<br>
<br> for (style=SOLID_LINE; style<=USERBIT_LINE; style++)
<br> {
<br> /* select the line style */
<br> setlinestyle(style, userpat, 1);
<br>
<br> /* convert style into a string */
<br> strcpy(stylestr, lname[style]);
<br>
<br> /* draw a line */
<br> line(0, 0, midx-10, midy);
<br>
<br> /* draw a rectangle */
<br> rectangle(0, 0, getmaxx(), getmaxy());
<br>
<br> /* output a message */
<br> outtextxy(midx, midy, stylestr);
<br>
<br> /* wait for a key */
<br> getch();
<br> cleardevice();
<br> }
<br>
<br> /* clean up */
<br> closegraph();
<br> return 0;
<br>}
<br>
<br>
<br>
<br>
<br>函数名: setmem
<br>功 能: 存值到存储区
<br>用 法: void setmem(void *addr, int len, char value);
<br>程序例:
<br>
<br>#include <stdio.h>
<br>#include <alloc.h>
<br>#include <mem.h>
<br>
<br>int main(void)
<br>{
<br> char *dest;
<br>
<br> dest = calloc(21, sizeof(char));
<br> setmem(dest, 20, 'c');
<br> printf("%s\n", dest);
<br>
<br> return 0;
<br>}
<br>
<br>
<br>
<br>
<br>函数名: setmode
<br>功 能: 设置打开文件方式
<br>用 法: int setmode(int handle, unsigned mode);
<br>程序例:
<br>
<br>#include <stdio.h>
<br>#include <fcntl.h>
<br>#include <io.h>
<br>
<br>int main(void)
<br>{
<br> int result;
<br>
<br> result = setmode(fileno(stdprn), O_TEXT);
<br> if (result == -1)
<br> perror("Mode not available\n");
<br> else
<br> printf("Mode successfully switched\n");
<br> return 0;
<br>}
<br>
<br>
<br>
<br>
<br>函数名: setpalette
<br>功 能: 改变调色板的颜色
<br>用 法: void far setpalette(int index, int actural_color);
<br>程序例:
<br>
<br>#include <graphics.h>
<br>#include <stdlib.h>
<br>#include <stdio.h>
<br>#include <conio.h>
<br>
<br>int main(void)
<br>{
<br> /* request auto detection */
<br> int gdriver = DETECT, gmode, errorcode;
<br> int color, maxcolor, ht;
<br> int y = 10;
<br> char msg[80];
<br>
<br> /* initialize graphics and local variables */
<br> initgraph(&gdriver, &gmode, "");
<br>
<br> /* 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> }
<br>
<br> maxcolor = getmaxcolor();
<br> ht = 2 * textheight("W");
<br>
<br> /* display the default colors */
<br> for (color=1; color<=maxcolor; color++)
<br> {
<br> setcolor(color);
<br> sprintf(msg, "Color: %d", color);
<br> outtextxy(1, y, msg);
<br> y += ht;
<br> }
<br>
<br> /* wait for a key */
<br> getch();
<br>
<br> /* black out the colors one by one */
<br> for (color=1; color<=maxcolor; color++)
<br> {
<br> setpalette(color, BLACK);
<br> getch();
<br> }
<br>
<br> /* clean up */
<br> closegraph();
<br> return 0;
<br>}
<br>
<br>
<br>
<br>函数名: setrgbpalette
<br>功 能: 定义IBM8514图形卡的颜色
<br>用 法: void far setrgbpalette(int colornum, int red, int green, int blue);
<br>程序例:
<br>
<br>#include <graphics.h>
<br>#include <stdlib.h>
<br>#include <stdio.h>
<br>#include <conio.h>
<br>
<br>int main(void)
<br>{
<br> /* select a driver and mode that supports the use */
<br> /* of the setrgbpalette function. */
<br> int gdriver = VGA, gmode = VGAHI, errorcode;
<br> struct palettetype pal;
<br> int i, ht, y, xmax;
<br>
<br> /* initialize graphics and local variables */
<br> initgraph(&gdriver, &gmode, "");
<br>
<br> /* 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> }
<br>
<br> /* grab a copy of the palette */
<br> getpalette(&pal);
<br>
<br> /* create gray scale */
<br> for (i=0; i<pal.size; i++)
<br> setrgbpalette(pal.colors[i], i*4, i*4, i*4);
<br>
<br> /* display the gray scale */
<br> ht = getmaxy() / 16;
<br> xmax = getmaxx();
<br> y = 0;
<br> for (i=0; i<pal.size; i++)
<br> {
<br> setfillstyle(SOLID_FILL, i);
<br> bar(0, y, xmax, y+ht);
<br> y += ht;
<br> }
<br>
<br> /* clean up */
<br> getch();
<br> closegraph();
<br> return 0;
<br>}
<br>
<br>
<br>
<br>
<br>函数名: settextjustify
<br>功 能: 为图形函数设置文本的对齐方式
<br>用 法: void far settextjustify(int horiz, int vert);
<br>程序例:
<br>
<br>#include <graphics.h>
<br>#include <stdlib.h>
<br>#include <stdio.h>
<br>#include <conio.h>
<br>
<br>/* function prototype */
<br>void xat(int x, int y);
<br>
<br>/* horizontal text justification settings */
<br>char *hjust[] = { "LEFT_TEXT",
<br> "CENTER_TEXT",
<br> "RIGHT_TEXT"
<br> };
<br>
<br>/* vertical text justification settings */
<br>char *vjust[] = { "LEFT_TEXT",
<br> "CENTER_TEXT",
<br> "RIGHT_TEXT"
<br> };
<br>
<br>int main(void)
<br>{
<br> /* request auto detection */
<br> int gdriver = DETECT, gmode, errorcode;
<br> int midx, midy, hj, vj;
<br> char msg[80];
<br>
<br> /* initialize graphics and local variables */
<br> initgraph(&gdriver, &gmode, "");
<br>
<br> /* 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> }
<br>
<br> midx = getmaxx() / 2;
<br> midy = getmaxy() / 2;
<br>
<br> /* loop through text justifications */
<br> for (hj=LEFT_TEXT; hj<=RIGHT_TEXT; hj++)
<br> for (vj=LEFT_TEXT; vj<=RIGHT_TEXT; vj++)
<br> {
<br> cleardevice();
<br> /* set the text justification */
<br> settextjustify(hj, vj);
<br>
<br> /* create a message string */
<br> sprintf(msg, "%s %s", hjust[hj], vjust[vj]);
<br>
<br> /* create cross hairs on the screen */
<br> xat(midx, midy);
<br>
<br> /* output the message */
<br> outtextxy(midx, midy, msg);
<br> getch();
<br> }
<br>
<br> /* clean up */
<br> closegraph();
<br> return 0;
<br>}
<br>
<br>/* draw an "x" at (x, y) */
<br>void xat(int x, int y)
<br>{
<br> line(x-4, y, x+4, y);
<br> line(x, y-4, x, y+4);
<br>}
<br>
<br>
<br>
<br>函数名: settextstyle
<br>功 能: 为图形输出设置当前的文本属性
<br>用 法: void far settextstyle (int font, int direction, char size);
<br>程序例:
<br>
<br>#include <graphics.h>
<br>#include <stdlib.h>
<br>#include <stdio.h>
<br>#include <conio.h>
<br>
<br>/* the names of the text styles supported */
<br>char *fname[] = { "DEFAULT font",
<br> "TRIPLEX font",
<br> "SMALL font",
<br> "SANS SERIF font",
<br> "GOTHIC font"
<br> };
<br>
<br>int main(void)
<br>{
<br> /* request auto detection */
<br> int gdriver = DETECT, gmode, errorcode;
<br> int style, midx, midy;
<br> int size = 1;
<br>
<br> /* initialize graphics and local variables */
<br> initgraph(&gdriver, &gmode, "");
<br>
<br> /* 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> }
<br>
<br> midx = getmaxx() / 2;
<br> midy = getmaxy() / 2;
<br>
<br> settextjustify(CENTER_TEXT, CENTER_TEXT);
<br>
<br> /* 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;
<br>
<br> /* select the text style */
<br> settextstyle(style, HORIZ_DIR, size);
<br>
<br> /* output a message */
<br> outtextxy(midx, midy, fname[style]);
<br> getch();
<br> }
<br>
<br> /* clean up */
<br> closegraph();
<br> return 0;
<br>}
<br>
<br>
<br>
<br>函数名: settextstyle
<br>功 能: 为图形输出设置当前的文本属性
<br>用 法: void far settextstyle (int font, int direction, char size);
<br>程序例:
<br>
<br>#include <graphics.h>
<br>#include <stdlib.h>
<br>#include <stdio.h>
<br>#include <conio.h>
<br>
<br>/* the names of the text styles supported */
<br>char *fname[] = { "DEFAULT font",
<br> "TRIPLEX font",
<br> "SMALL font",
<br> "SANS SERIF font",
<br> "GOTHIC font"
<br> };
<br>
<br>int main(void)
<br>{
<br> /* request auto detection */
<br> int gdriver = DETECT, gmode, errorcode;
<br> int style, midx, midy;
<br> int size = 1;
<br>
<br> /* initialize graphics and local variables */
<br> initgraph(&gdriver, &gmode, "");
<br>
<br> /* 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> }
<br>
<br> midx = getmaxx() / 2;
<br> midy = getmaxy() / 2;
<br>
<br> settextjustify(CENTER_TEXT, CENTER_TEXT);
<br>
<br> /* 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;
<br>
<br> /* select the text style */
<br> settextstyle(style, HORIZ_DIR, size);
<br>
<br> /* output a message */
<br> outtextxy(midx, midy, fname[style]);
<br> getch();
<br> }
<br>
<br> /* clean up */
<br> closegraph();
<br> return 0;
<br>}
<br>
<br>
<br>
<br>函数名: settime
<br>功 能: 设置系统时间
<br>用 法: void settime(struct time *timep);
<br>程序例:
<br>
<br>#include <stdio.h>
<br>#include <dos.h>
<br>
<br>int main(void)
<br>{
<br> struct time t;
<br>
<br> 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);
<br>
<br> /* Add one to the minutes struct element and then call settime */
<br> t.ti_min++;
<br> settime(&t);
<br>
<br> return 0;
<br>}
<br>
<br>
<br>
<br>函数名: setusercharsize
<br>功 能: 为矢量字体改变字符宽度和高度
<br>用 法: void far setusercharsize(int multx, int dirx, int multy, int diry);
<br>程序例:
<br>
<br>#include <graphics.h>
<br>#include <stdlib.h>
<br>#include <stdio.h>
<br>#include <conio.h>
<br>
<br>int main(void)
<br>{
<br> /* request autodetection */
<br> int gdriver = DETECT, gmode, errorcode;
<br>
<br> /* initialize graphics and local variables */
<br> initgraph(&gdriver, &gmode, "");
<br>
<br> /* 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> }
<br>
<br> /* select a text style */
<br> settextstyle(TRIPLEX_FONT, HORIZ_DIR, 4);
<br>
<br> /* move to the text starting position */
<br> moveto(0, getmaxy() / 2);
<br>
<br> /* output some normal text */
<br> outtext("Norm ");
<br>
<br> /* make the text 1/3 the normal width */
<br> setusercharsize(1, 3, 1, 1);
<br> outtext("Short ");
<br>
<br> /* make the text 3 times normal width */
<br> setusercharsize(3, 1, 1, 1);
<br> outtext("Wide");
<br>
<br> /* clean up */
<br> getch();
<br> closegraph();
<br> return 0;
<br>}
<br>
<br>
<br>函数名: setvbuf
<br>功 能: 把缓冲区与流相关
<br>用 法: int setvbuf(FILE *stream, char *buf, int type, unsigned size);
<br>程序例:
<br>
<br>#include <stdio.h>
<br>
<br>int main(void)
<br>{
<br> FILE *input, *output;
<br> char bufr[512];
<br>
<br> input = fopen("file.in", "r+b");
<br> output = fopen("file.out", "w");
<br>
<br> /* 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");
<br>
<br> /* 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");
<br>
<br> /* perform file I/O here */
<br>
<br> /* close files */
<br> fclose(input);
<br> fclose(output);
<br> return 0;
<br>}
<br>
<br>
<br>
<br>
<br>函数名: setvect
<br>功 能: 设置中断矢量入口
<br>用 法: void setvect(int intr_num, void interrupt(*isr)());
<br>程序例:
<br>
<br>/***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. */
<br>
<br>#include <stdio.h>
<br>#include <dos.h>
<br>#include <conio.h>
<br>
<br>#define INTR 0X1C /* The clock tick interrupt */
<br>
<br>void interrupt ( *oldhandler)(void);
<br>
<br>int count=0;
<br>
<br>void interrupt handler(void)
<br>{
<br>/* increase the global counter */
<br> count++;
<br>
<br>/* call the old routine */
<br> oldhandler();
<br>}
<br>
<br>int main(void)
<br>{
<br>/* save the old interrupt vector */
<br> oldhandler = getvect(INTR);
<br>
<br>/* install the new interrupt handler */
<br> setvect(INTR, handler);
<br>
<br>/* loop until the counter exceeds 20 */
<br> while (count < 20)
<br> printf("count is %d\n",count);
<br>
<br>/* reset the old interrupt handler */
<br> setvect(INTR, oldhandler);
<br>
<br> return 0;
<br>}
<br>
<br>
<br>
<br>函数名: setverify
<br>功 能: 设置验证状态
<br>用 法: void setverify(int value);
<br>程序例:
<br>
<br>#include <stdio.h>
<br>#include <conio.h>
<br>#include <dos.h>
<br>
<br>int main(void)
<br>{
<br> int verify_flag;
<br>
<br> printf("Enter 0 to set verify flag off\n");
<br> printf("Enter 1 to set verify flag on\n");
<br>
<br> verify_flag = getch() - 0;
<br>
<br> setverify(verify_flag);
<br>
<br> if (getverify())
<br> printf("DOS verify flag is on\n");
<br> else
<br> printf("DOS verify flag is off\n");
<br>
<br> return 0;
<br>}
<br>
<br>
<br>
<br>函数名: setviewport
<br>功 能: 为图形输出设置当前视口
<br>用 法: void far setviewport(int left, int top, int right,
<br> int bottom, int clipflag);
<br>程序例:
<br>
<br>#include <graphics.h>
<br>#include <stdlib.h>
<br>#include <stdio.h>
<br>#include <conio.h>
<br>
<br>#define CLIP_ON 1 /* activates clipping in viewport */
<br>
<br>int main(void)
<br>{
<br> /* request auto detection */
<br> int gdriver = DETECT, gmode, errorcode;
<br>
<br> /* initialize graphics and local variables */
<br> initgraph(&gdriver, &gmode, "");
<br>
<br> /* 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> }
<br>
<br> setcolor(getmaxcolor());
<br>
<br> /* message in default full-screen viewport */
<br> outtextxy(0, 0, "* <-- (0, 0) in default viewport");
<br>
<br> /* create a smaller viewport */
<br> setviewport(50, 50, getmaxx()-50, getmaxy()-50, CLIP_ON);
<br>
<br> /* display some text */
<br> outtextxy(0, 0, "* <-- (0, 0) in smaller viewport");
<br>
<br> /* clean up */
<br> getch();
<br> closegraph();
<br> return 0;
<br>}
<br>
<br>
<br>
<br>函数名: setvisualpage
<br>功 能: 设置可见图形页号
<br>用 法: void far setvisualpage(int pagenum);
<br>程序例:
<br>
<br>#include <graphics.h>
<br>#include <stdlib.h>
<br>#include <stdio.h>
<br>#include <conio.h>
<br>
<br>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;
<br>
<br> /* initialize graphics and local variables */
<br> initgraph(&gdriver, &gmode, "");
<br>
<br> /* 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> }
<br>
<br> x = getmaxx() / 2;
<br> y = getmaxy() / 2;
<br> ht = textheight("W");
<br>
<br> /* select the off screen page for drawing */
<br> setactivepage(1);
<br>
<br> /* draw a line on page #1 */
<br> line(0, 0, getmaxx(), getmaxy());
<br>
<br> /* 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:");
<br>
<br> /* select drawing to page #0 */
<br> setactivepage(0);
<br>
<br> /* 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();
<br>
<br> /* select page #1 as the visible page */
<br> setvisualpage(1);
<br>
<br> /* clean up */
<br> getch();
<br> closegraph();
<br> return 0;
<br>}
<br>
<br>
<br>
<br>函数名: setwritemode
<br>功 能: 设置图形方式下画线的输出模式
<br>用 法: void far setwritemode(int mode);
<br>程序例:
<br>
<br>#include <graphics.h>
<br>#include <stdlib.h>
<br>#include <stdio.h>
<br>#include <conio.h>
<br>
<br>int main()
<br>{
<br> /* request auto detection */
<br> int gdriver = DETECT, gmode, errorcode;
<br> int xmax, ymax;
<br>
<br> /* initialize graphics and local variables */
<br> initgraph(&gdriver, &gmode, "");
<br>
<br> /* 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> }
<br>
<br> xmax = getmaxx();
<br> ymax = getmaxy();
<br>
<br> /* select XOR drawing mode */
<br> setwritemode(XOR_PUT);
<br>
<br> /* draw a line */
<br> line(0, 0, xmax, ymax);
<br> getch();
<br>
<br> /* erase the line by drawing over it */
<br> line(0, 0, xmax, ymax);
<br> getch();
<br>
<br> /* select overwrite drawing mode */
<br> setwritemode(COPY_PUT);
<br>
<br> /* draw a line */
<br> line(0, 0, xmax, ymax);
<br>
<br> /* clean up */
<br> getch();
<br> closegraph();
<br> return 0;
<br>}
<br>
<br>
<br>
<br>函数名: signal
<br>功 能: 设置某一信号的对应动作
<br>用 法: int signal(int sig, sigfun fname);
<br>程序例:
<br>
<br>/* 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 MAY cause
<br> your computer to crash, and will produce runtime errors
<br> depending on which memory model is used.
<br>*/
<br>
<br>#pragma inline
<br>#include <stdio.h>
<br>#include <signal.h>
<br>
<br>void Catcher(int sig, int type, int *reglist)
<br>{
<br> printf("Caught it!\n");
<br> *(reglist + 8) = 3; /* make return AX = 3 */
<br>}
<br>
<br>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 */
<br>
<br> /* The handler set AX to 3 on return. If that hadn't happened,
<br> there would have been another exception when the next 'into'
<br> was executed after the 'dec' instruction. */
<br> asm dec ax /* no overflow now */
<br> asm into /* doesn't activate */
<br> return 0;
<br>}
<br>
<br>
<br>
<br>
<br>函数名: sin
<br>功 能: 正弦函数
<br>用 法: double sin(double x);
<br>程序例:
<br>
<br>#include <stdio.h>
<br>#include <math.h>
<br>
<br>int main(void)
<br>{
<br> double result, x = 0.5;
<br>
<br> result = sin(x);
<br> printf("The sin() of %lf is %lf\n", x, result);
<br> return 0;
<br>}
<br>
<br>
<br>
<br>函数名: sinh
<br>功 能: 双曲正弦函数
<br>用 法: double sinh(double x);
<br>程序例:
<br>
<br>#include <stdio.h>
<br>#include <math.h>
<br>
<br>int main(void)
<br>{
<br> double result, x = 0.5;
<br>
<br> result = sinh(x);
<br> printf("The hyperbolic sin() of %lf is %lf\n", x, result);
<br> return 0;
<br>}
<br>
<br>
<br>
<br>
<br>函数名: sleep
<br>功 能: 执行挂起一段时间
<br>用 法: unsigned sleep(unsigned seconds);
<br>程序例:
<br>
<br>#include <dos.h>
<br>#include <stdio.h>
<br>
<br>int main(void)
<br>{
<br> int i;
<br>
<br> for (i=1; i<5; i++)
<br> {
<br> printf("Sleeping for %d seconds\n", i);
<br> sleep(i);
<br> }
<br> return 0;
<br>}
<br>
<br>
<br>
<br>
<br>函数名: sopen
<br>功 能: 打开一共享文件
<br>用 法: int sopen(char *pathname, int access, int shflag, int permiss);
<br>程序例:
<br>
<br>#include <io.h>
<br>#include <fcntl.h>
<br>#include <sys\stat.h>
<br>#include <process.h>
<br>#include <share.h>
<br>#include <stdio.h>
<br>
<br>int main(void)
<br>{
<br> int handle;
<br> int status;
<br>
<br> handle = sopen("c:\\autoexec.bat", O_RDONLY, SH_DENYNO, S_IREAD);
<br>
<br> if (!handle)
<br> {
<br> printf("sopen failed\n");
<br> exit(1);
<br> }
<br>
<br> status = access("c:\\autoexec.bat", 6);
<br> if (status == 0)
<br> printf("read/write access allowed\n");
<br> else
<br> printf("read/write access not allowed\n");
<br>
<br> close(handle);
<br> return 0;
<br>}
<br> (<a href=http://www.fanqiang.com>http://www.fanqiang.com</a>)</font> 进入【<a href=http://www.chinaunix.net>UNIX论坛</a>】</td></tr><tr><td><hr></td></tr><tr><td><b>相关文章</b> </td></tr><tr><td><a href=/a4/b2/20011027/1305001515.html>C语言库函数(W类字母)</a> <small>(2001-10-27 13:05:00)</small></font><br><a href=/a4/b2/20011027/0905001514.html>C语言库函数(V类字母)</a> <small>(2001-10-27 09:05:00)</small></font><br><a href=/a4/b2/20011027/0805011513.html>C语言库函数(U类字母)</a> <small>(2001-10-27 08:05:01)</small></font><br><a href=/a4/b2/20011027/0705001512.html>C语言库函数(T类字母)</a> <small>(2001-10-27 07:05:00)</small></font><br><a href=/a4/b2/20011026/0900001511.html>C语言库函数(S类字母) - 3</a> <small>(2001-10-26 09:00:00)</small></font><br><a href=/a4/b2/20011026/0800011510.html>C语言库函数(S类字母) - 2</a> <small>(2001-10-26 08:00:01)</small></font><br><a href=/a4/b2/20011026/0700001509.html>C语言库函数(S类字母) - 1</a> <small>(2001-10-26 07:00:00)</small></font><br><a href=/a4/b2/20011025/0900011508.html>C语言库函数(R类字母)</a> <small>(2001-10-25 09:00:01)</small></font><br><a href=/a4/b2/20011025/0800031507.html>C语言库函数(Q类字母)</a> <small>(2001-10-25 08:00:03)</small></font><br><a href=/a4/b2/20011025/0700011506.html>C语言库函数(P类字母)</a> <small>(2001-10-25 07:00:01)</small></font><br></td></tr><tr>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -