?? fs.htm
字號:
<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>
<P>函數名: sbrk
<BR>功 能: 改變數據段空間位置
<BR>用 法: char *sbrk(int incr);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <alloc.h>
<P>int main(void)
<BR>{
<BR> printf("Changing allocation with sbrk()\n");
<BR> printf("Before sbrk() call: %lu bytes free\n",
<BR> (unsigned long) coreleft());
<BR> sbrk(1000);
<BR> printf(" After sbrk() call: %lu bytes free\n",
<BR> (unsigned long) coreleft());
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函數名: scanf
<BR>功 能: 執行格式化輸入
<BR>用 法: int scanf(char *format[,argument,...]);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <conio.h>
<P>int main(void)
<BR>{
<BR> char label[20];
<BR> char name[20];
<BR> int entries = 0;
<BR> int loop, age;
<BR> double salary;
<P> struct Entry_struct
<BR> {
<BR> char name[20];
<BR> int age;
<BR> float salary;
<BR> } entry[20];
<P>/* Input a label as a string of characters restricting to 20 characters
*/
<BR> printf("\n\nPlease enter a label for the chart: ");
<BR> scanf("%20s", label);
<BR> fflush(stdin); /* flush the input stream in case
of bad input */
<P>/* Input number of entries as an integer */
<BR> printf("How many entries will there be? (less than 20)
");
<BR> scanf("%d", &entries);
<BR> fflush(stdin); /* flush the input stream in
case of bad input */
<P>/* input a name restricting input to only letters upper or lower case
*/
<BR> for (loop=0;loop<entries;++loop)
<BR> {
<BR> printf("Entry %d\n", loop);
<BR> printf(" Name : ");
<BR> scanf("%[A-Za-z]", entry[loop].name);
<BR> fflush(stdin); /* flush the input
stream in case of bad input */
<P>/* input an age as an integer */
<BR> printf(" Age
: ");
<BR> scanf("%d", &entry[loop].age);
<BR> fflush(stdin); /* flush the input
stream in case of bad input */
<P>/* input a salary as a float */
<BR> printf(" Salary : ");
<BR> scanf("%f", &entry[loop].salary);
<BR> fflush(stdin); /* flush the input stream
in case of bad input */
<BR> }
<P>/* Input a name, age and salary as a string, integer, and double */
<BR> printf("\nPlease enter your name, age and salary\n");
<BR> scanf("%20s %d %lf", name, &age, &salary);
<BR>
<P>/* Print out the data that was input */
<BR> printf("\n\nTable %s\n",label);
<BR> printf("Compiled by %s age %d $%15.2lf\n",
name, age, salary);
<BR> printf("-----------------------------------------------------\n");
<BR> for (loop=0;loop<entries;++loop)
<BR> printf("%4d | %-20s | %5d | %15.2lf\n",
<BR> loop + 1,
<BR> entry[loop].name,
<BR> entry[loop].age,
<BR> entry[loop].salary);
<BR> printf("-----------------------------------------------------\n");
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函數名: searchpath
<BR>功 能: 搜索DOS路徑
<BR>用 法: char *searchpath(char *filename);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <dir.h>
<P>int main(void)
<BR>{
<BR> char *p;
<P> /* Looks for TLINK and returns a pointer
<BR> to the path */
<BR> p = searchpath("TLINK.EXE");
<BR> printf("Search for TLINK.EXE : %s\n", p);
<P> /* Looks for non-existent file */
<BR> p = searchpath("NOTEXIST.FIL");
<BR> printf("Search for NOTEXIST.FIL : %s\n", p);
<P> return 0;
<BR>}
<BR>
<BR>
<P>函數名: sector
<BR>功 能: 畫并填充橢圓扇區
<BR>用 法: void far sector(int x, int y, int stangle, int endangle);
<BR>程序例:
<P>#include <graphics.h>
<BR>#include <stdlib.h>
<BR>#include <stdio.h>
<BR>#include <conio.h>
<P>int main(void)
<BR>{
<BR> /* request auto detection */
<BR> int gdriver = DETECT, gmode, errorcode;
<BR> int midx, midy, i;
<BR> int stangle = 45, endangle = 135;
<BR> int xrad = 100, yrad = 50;
<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> midx = getmaxx() / 2;
<BR> midy = getmaxy() / 2;
<P> /* loop through the fill patterns */
<BR> for (i=EMPTY_FILL; i<USER_FILL; i++)
<BR> {
<BR> /* set the fill style */
<BR> setfillstyle(i, getmaxcolor());
<P> /* draw the sector slice */
<BR> sector(midx, midy, stangle, endangle,
xrad, yrad);
<P> getch();
<BR> }
<P> /* clean up */
<BR> closegraph();
<BR> return 0;
<BR>}
<BR>
<P>函數名: segread
<BR>功 能: 讀段寄存器值
<BR>用 法: void segread(struct SREGS *segtbl);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <dos.h>
<P>int main(void)
<BR>{
<BR> struct SREGS segs;
<P> segread(&segs);
<BR> printf("Current segment register settings\n\n");
<BR> printf("CS: %X DS: %X\n", segs.cs, segs.ds);
<BR> printf("ES: %X SS: %X\n", segs.es, segs.ss);
<P> return 0;
<BR>}
<BR>
<BR>
<P>函數名: setactivepage
<BR>功 能: 設置圖形輸出活動頁
<BR>用 法: void far setactivepage(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>函數名: setallpallette
<BR>功 能: 按指定方式改變所有的調色板顏色
<BR>用 法: void far setallpallette(struct palette, far *pallette);
<BR>程序例:
<P>#include <graphics.h>
<BR>#include <stdlib.h>
<BR>#include <stdio.h>
<BR>#include <conio.h>
<P>int main(void)
<BR>{
<BR> /* request auto detection */
<BR> int gdriver = DETECT, gmode, errorcode;
<BR> struct palettetype pal;
<BR> int color, maxcolor, ht;
<BR> int y = 10;
<BR> char msg[80];
<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> maxcolor = getmaxcolor();
<BR> ht = 2 * textheight("W");
<P> /* grab a copy of the palette */
<BR> getpalette(&pal);
<P> /* display the default palette 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> }
<P> /* wait for a key */
<BR> getch();
<P> /* black out the colors one by one */
<BR> for (color=1; color<=maxcolor; color++)
<BR> {
<BR> setpalette(color, BLACK);
<BR> getch();
<BR> }
<P> /* restore the palette colors */
<BR> setallpalette(&pal);
<P> /* clean up */
<BR> getch();
<BR> closegraph();
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函數名: setaspectratio
<BR>功 能: 設置圖形縱橫比
<BR>用 法: void far setaspectratio(int xasp, int yasp);
<BR>程序例:
<P>#include <graphics.h>
<BR>#include <stdlib.h>
<BR>#include <stdio.h>
<BR>#include <conio.h>
<P>int main(void)
<BR>{
<BR> /* request auto detection */
<BR> int gdriver = DETECT, gmode, errorcode;
<BR> int xasp, yasp, midx, midy;
<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> midx = getmaxx() / 2;
<BR> midy = getmaxy() / 2;
<BR> setcolor(getmaxcolor());
<P> /* get current aspect ratio settings */
<BR> getaspectratio(&xasp, &yasp);
<P> /* draw normal circle */
<BR> circle(midx, midy, 100);
<BR> getch();
<P> /* claer the screen */
<BR> cleardevice();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -