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

📄 fs.htm

📁 turbo c
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<HTML><HEAD>   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">   <META NAME="Author" CONTENT="wdg">   <META NAME="GENERATOR" CONTENT="Mozilla/4.03 [en] (Win95; I) [Netscape]">   <TITLE>fs</TITLE></HEAD><BODY>&nbsp;<P>函数名: sbrk<BR>功&nbsp; 能: 改变数据段空间位置<BR>用&nbsp; 法: char *sbrk(int incr);<BR>程序例:<P>#include &lt;stdio.h><BR>#include &lt;alloc.h><P>int main(void)<BR>{<BR>&nbsp;&nbsp; printf("Changing allocation with sbrk()\n");<BR>&nbsp;&nbsp; printf("Before sbrk() call: %lu bytes free\n",<BR>&nbsp;&nbsp; (unsigned long) coreleft());<BR>&nbsp;&nbsp; sbrk(1000);<BR>&nbsp;&nbsp; printf(" After sbrk() call: %lu bytes free\n",<BR>&nbsp;&nbsp; (unsigned long) coreleft());<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: scanf<BR>功&nbsp; 能: 执行格式化输入<BR>用&nbsp; 法: int scanf(char *format[,argument,...]);<BR>程序例:<P>#include &lt;stdio.h><BR>#include &lt;conio.h><P>int main(void)<BR>{<BR>&nbsp;&nbsp; char label[20];<BR>&nbsp;&nbsp; char name[20];<BR>&nbsp;&nbsp; int entries = 0;<BR>&nbsp;&nbsp; int loop, age;<BR>&nbsp;&nbsp; double salary;<P>&nbsp;&nbsp; struct Entry_struct<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char&nbsp; name[20];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int&nbsp;&nbsp; age;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; float salary;<BR>&nbsp;&nbsp; } entry[20];<P>/* Input a label as a string of characters restricting to 20 characters*/<BR>&nbsp;&nbsp; printf("\n\nPlease enter a label for the chart: ");<BR>&nbsp;&nbsp; scanf("%20s", label);<BR>&nbsp;&nbsp; fflush(stdin);&nbsp; /* flush the input stream in caseof bad input */<P>/* Input number of entries as an integer */<BR>&nbsp;&nbsp; printf("How many entries will there be? (less than 20)");<BR>&nbsp;&nbsp; scanf("%d", &amp;entries);<BR>&nbsp;&nbsp; fflush(stdin);&nbsp;&nbsp; /* flush the input stream incase of bad input */<P>/* input a name restricting input to only letters upper or lower case*/<BR>&nbsp;&nbsp; for (loop=0;loop&lt;entries;++loop)<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Entry %d\n", loop);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("&nbsp; Name&nbsp;&nbsp; : ");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; scanf("%[A-Za-z]", entry[loop].name);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fflush(stdin);&nbsp; /* flush the inputstream in case of bad input */<P>/* input an age as an integer */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("&nbsp; Age&nbsp;&nbsp;&nbsp;: ");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; scanf("%d", &amp;entry[loop].age);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fflush(stdin);&nbsp; /* flush the inputstream in case of bad input */<P>/* input a salary as a float */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("&nbsp; Salary : ");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; scanf("%f", &amp;entry[loop].salary);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fflush(stdin); /* flush the input streamin case of bad input */<BR>&nbsp;&nbsp; }<P>/* Input a name, age and salary as a string, integer, and double */<BR>&nbsp;&nbsp; printf("\nPlease enter your name, age and salary\n");<BR>&nbsp;&nbsp; scanf("%20s %d %lf", name, &amp;age, &amp;salary);<BR>&nbsp;<P>/* Print out the data that was input */<BR>&nbsp;&nbsp; printf("\n\nTable %s\n",label);<BR>&nbsp;&nbsp; printf("Compiled by %s&nbsp; age %d&nbsp; $%15.2lf\n",name, age, salary);<BR>&nbsp;&nbsp; printf("-----------------------------------------------------\n");<BR>&nbsp;&nbsp; for (loop=0;loop&lt;entries;++loop)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("%4d | %-20s | %5d | %15.2lf\n",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; loop + 1,<BR>&nbsp; entry[loop].name,<BR>&nbsp; entry[loop].age,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry[loop].salary);<BR>&nbsp;&nbsp; printf("-----------------------------------------------------\n");<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: searchpath<BR>功&nbsp; 能: 搜索DOS路径<BR>用&nbsp; 法: char *searchpath(char *filename);<BR>程序例:<P>#include &lt;stdio.h><BR>#include &lt;dir.h><P>int main(void)<BR>{<BR>&nbsp;&nbsp; char *p;<P>&nbsp;&nbsp; /* Looks for TLINK and returns a pointer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; to the path&nbsp; */<BR>&nbsp;&nbsp; p = searchpath("TLINK.EXE");<BR>&nbsp;&nbsp; printf("Search for TLINK.EXE : %s\n", p);<P>&nbsp;&nbsp; /* Looks for non-existent file&nbsp; */<BR>&nbsp;&nbsp; p = searchpath("NOTEXIST.FIL");<BR>&nbsp;&nbsp; printf("Search for NOTEXIST.FIL : %s\n", p);<P>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: sector<BR>功&nbsp; 能: 画并填充椭圆扇区<BR>用&nbsp; 法: void far sector(int x, int y, int stangle, int endangle);<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 midx, midy, i;<BR>&nbsp;&nbsp; int stangle = 45, endangle = 135;<BR>&nbsp;&nbsp; int xrad = 100, yrad = 50;<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; /* loop through the fill patterns */<BR>&nbsp;&nbsp; for (i=EMPTY_FILL; i&lt;USER_FILL; i++)<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* set the fill style */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setfillstyle(i, getmaxcolor());<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* draw the sector slice */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sector(midx, midy, stangle, endangle,xrad, yrad);<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getch();<BR>&nbsp;&nbsp; }<P>&nbsp;&nbsp; /* clean up */<BR>&nbsp;&nbsp; closegraph();<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<P>函数名: segread<BR>功&nbsp; 能: 读段寄存器值<BR>用&nbsp; 法: void segread(struct SREGS *segtbl);<BR>程序例:<P>#include &lt;stdio.h><BR>#include &lt;dos.h><P>int main(void)<BR>{<BR>&nbsp;&nbsp; struct SREGS segs;<P>&nbsp;&nbsp; segread(&amp;segs);<BR>&nbsp;&nbsp; printf("Current segment register settings\n\n");<BR>&nbsp;&nbsp; printf("CS: %X&nbsp;&nbsp; DS: %X\n", segs.cs, segs.ds);<BR>&nbsp;&nbsp; printf("ES: %X&nbsp;&nbsp; SS: %X\n", segs.es, segs.ss);<P>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: setactivepage<BR>功&nbsp; 能: 设置图形输出活动页<BR>用&nbsp; 法: void far setactivepage(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>函数名: setallpallette<BR>功&nbsp; 能: 按指定方式改变所有的调色板颜色<BR>用&nbsp; 法: void far setallpallette(struct palette, far *pallette);<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; struct palettetype pal;<BR>&nbsp;&nbsp; int color, maxcolor, ht;<BR>&nbsp;&nbsp; int y = 10;<BR>&nbsp;&nbsp; char msg[80];<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; maxcolor = getmaxcolor();<BR>&nbsp;&nbsp; ht = 2 * textheight("W");<P>&nbsp;&nbsp; /* grab a copy of the palette */<BR>&nbsp;&nbsp; getpalette(&amp;pal);<P>&nbsp;&nbsp; /* display the default palette colors */<BR>&nbsp;&nbsp; for (color=1; color&lt;=maxcolor; color++)<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setcolor(color);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sprintf(msg, "Color: %d", color);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outtextxy(1, y, msg);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; y += ht;<BR>&nbsp;&nbsp; }<P>&nbsp;&nbsp; /* wait for a key */<BR>&nbsp;&nbsp; getch();<P>&nbsp;&nbsp; /* black out the colors one by one */<BR>&nbsp;&nbsp; for (color=1; color&lt;=maxcolor; color++)<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setpalette(color, BLACK);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getch();<BR>&nbsp;&nbsp; }<P>&nbsp;&nbsp; /* restore the palette colors */<BR>&nbsp;&nbsp; setallpalette(&amp;pal);<P>&nbsp;&nbsp; /* clean up */<BR>&nbsp;&nbsp; getch();<BR>&nbsp;&nbsp; closegraph();<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: setaspectratio<BR>功&nbsp; 能: 设置图形纵横比<BR>用&nbsp; 法: void far setaspectratio(int xasp, int yasp);<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 xasp, yasp, midx, midy;<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;<BR>&nbsp;&nbsp; setcolor(getmaxcolor());<P>&nbsp;&nbsp; /* get current aspect ratio settings */<BR>&nbsp;&nbsp; getaspectratio(&amp;xasp, &amp;yasp);<P>&nbsp;&nbsp; /* draw normal circle */<BR>&nbsp;&nbsp; circle(midx, midy, 100);<BR>&nbsp;&nbsp; getch();<P>&nbsp;&nbsp; /* claer the screen */<BR>&nbsp;&nbsp; cleardevice();<P>&nbsp;&nbsp; /* adjust the aspect for a wide circle */<BR>&nbsp;&nbsp; setaspectratio(xasp/2, yasp);<BR>&nbsp;&nbsp; circle(midx, midy, 100);<BR>&nbsp;&nbsp; getch();<P>&nbsp;&nbsp; /* adjust the aspect for a narrow circle */<BR>&nbsp;&nbsp; cleardevice();<BR>&nbsp;&nbsp; setaspectratio(xasp, yasp/2);<BR>&nbsp;&nbsp; circle(midx, midy, 100);<P>&nbsp;&nbsp; /* clean up */

⌨️ 快捷键说明

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