?? fg.htm
字號(hào):
<BR>#include <conio.h>
<P>int main(void)
<BR>{
<BR>/* request auto detection */
<BR> int gdriver = DETECT, gmode, errorcode;
<BR> int color, midx, midy;
<BR> char colname[35];
<P>/* initialize graphics and local variables */
<BR> initgraph(&gdriver, &gmode, "");
<P>/* read result of initialization */
<BR> errorcode = graphresult();
<BR>/* an error occurred */
<BR> if (errorcode != grOk)
<BR> {
<BR> printf("Graphics error: %s\n",
<BR>
grapherrormsg(errorcode));
<BR> printf("Press any key to halt:");
<BR> getch();
<BR>/* terminate with an error code */
<BR> exit(1);
<BR> }
<P> midx = getmaxx() / 2;
<BR> midy = getmaxy() / 2;
<BR> setcolor(getmaxcolor());
<P>/* for centering text on the display */
<BR> settextjustify(CENTER_TEXT, CENTER_TEXT);
<P>/* get the current drawing color */
<BR> color = getcolor();
<P>/* convert color value into a string */
<BR> itoa(color, colname, 10);
<BR> strcat(colname,
<BR> " is the current drawing color.");
<P>/* display a message */
<BR> outtextxy(midx, midy, colname);
<P>/* clean up */
<BR> getch();
<BR> closegraph();
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函數(shù)名: getcurdir
<BR>功 能: 取指定驅(qū)動(dòng)器的當(dāng)前目錄
<BR>用 法: int getcurdir(int drive, char *direc);
<BR>程序例:
<P>#include <dir.h>
<BR>#include <stdio.h>
<BR>#include <string.h>
<P>char *current_directory(char *path)
<BR>{
<BR> strcpy(path, "X:\\"); /*
fill string with form of response: X:\ */
<BR> path[0] = 'A' + getdisk(); /* replace
X with current drive letter */
<BR> getcurdir(0, path+3); /* fill rest of string with
current directory */
<BR> return(path);
<BR>}
<P>int main(void)
<BR>{
<BR> char curdir[MAXPATH];
<P> current_directory(curdir);
<BR> printf("The current directory is %s\n", curdir);
<P> return 0;
<BR>}
<BR>
<BR>
<P>函數(shù)名: getcwd
<BR>功 能: 取當(dāng)前工作目錄
<BR>用 法: char *getcwd(char *buf, int n);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <dir.h>
<P>int main(void)
<BR>{
<BR> char buffer[MAXPATH];
<P> getcwd(buffer, MAXPATH);
<BR> printf("The current directory is: %s\n", buffer);
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函數(shù)名: getdate
<BR>功 能: 取DOS日期
<BR>用 法: void getdate(struct *dateblk);
<BR>程序例:
<P>#include <dos.h>
<BR>#include <stdio.h>
<P>int main(void)
<BR>{
<BR> struct date d;
<P> getdate(&d);
<BR> printf("The current year is: %d\n",
<BR> d.da_year);
<BR> printf("The current day is: %d\n",
<BR> d.da_day);
<BR> printf("The current month is: %d\n",
<BR> d.da_mon);
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函數(shù)名: getdefaultpalette
<BR>功 能: 返回調(diào)色板定義結(jié)構(gòu)
<BR>用 法: struct palettetype *far getdefaultpalette(void);
<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 i;
<P>/* structure for returning palette copy */
<BR> struct palettetype far *pal=(void *) 0;
<P>/* initialize graphics and local variables */
<BR> initgraph(&gdriver, &gmode, "");
<P>/* read result of initialization */
<BR> errorcode = graphresult();
<BR>/* an error occurred */
<BR> if (errorcode != grOk)
<BR> {
<BR> printf("Graphics error: %s\n",
<BR>
grapherrormsg(errorcode));
<BR> printf("Press any key to halt:");
<BR> getch();
<BR>/* terminate with an error code */
<BR> exit(1);
<BR> }
<P> setcolor(getmaxcolor());
<P>/* return a pointer to the default palette */
<BR> pal = getdefaultpalette();
<P> for (i=0; i<16; i++)
<BR> {
<BR> printf("colors[%d] = %d\n", i,
<BR>
pal->colors[i]);
<BR> getch();
<BR> }
<P>/* clean up */
<BR> getch();
<BR> closegraph();
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函數(shù)名: getdisk
<BR>功 能: 取當(dāng)前磁盤驅(qū)動(dòng)器號(hào)
<BR>用 法: int getdisk(void);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <dir.h>
<P>int main(void)
<BR>{
<BR> int disk;
<P> disk = getdisk() + 'A';
<BR> printf("The current drive is: %c\n",
<BR> disk);
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: getdrivername
<BR>功 能: 返回指向包含當(dāng)前圖形驅(qū)動(dòng)程序名字的字符串指針
<BR>用 法: char *getdrivename(void);
<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;
<P>/* stores the device driver name */
<BR> char *drivername;
<P>/* initialize graphics and local variables */
<BR> initgraph(&gdriver, &gmode, "");
<P>/* read result of initialization */
<BR> errorcode = graphresult();
<BR>/* an error occurred */
<BR> if (errorcode != grOk)
<BR> {
<BR> printf("Graphics error: %s\n",
<BR>
grapherrormsg(errorcode));
<BR> printf("Press any key to halt:");
<BR> getch();
<BR>/* terminate with an error code */
<BR> exit(1);
<BR> }
<P> setcolor(getmaxcolor());
<P>/* get name of the device driver in use */
<BR> drivername = getdrivername();
<P>/* for centering text on the screen */
<BR> settextjustify(CENTER_TEXT, CENTER_TEXT);
<P>/* output the name of the driver */
<BR> outtextxy(getmaxx() / 2, getmaxy() / 2,
<BR> drivername);
<P>/* clean up */
<BR> getch();
<BR> closegraph();
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函數(shù)名: getdta
<BR>功 能: 取磁盤傳輸?shù)刂?<BR>用 法: char far *getdta(void);
<BR>程序例:
<P>#include <dos.h>
<BR>#include <stdio.h>
<P>int main(void)
<BR>{
<BR> char far *dta;
<P> dta = getdta();
<BR> printf("The current disk transfer \
<BR> address is: %Fp\n", dta);
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函數(shù)名: getenv
<BR>功 能: 從環(huán)境中取字符串
<BR>用 法: char *getenv(char *envvar);
<BR>程序例:
<P>#include <stdlib.h>
<BR>#include <stdio.h>
<BR>
<P>int main(void)
<BR>{
<BR> char *s;
<P> s=getenv("COMSPEC");
/* get the comspec environment parameter */
<BR> printf("Command processor: %s\n",s);
/* display comspec parameter */
<P> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: getfat, getfatd
<BR>功 能: 取文件分配表信息
<BR>用 法: void getfat(int drive, struct fatinfo *fatblkp);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <dos.h>
<P>int main(void)
<BR>{
<BR> struct fatinfo diskinfo;
<BR> int flag = 0;
<P> printf("Please insert disk in drive A\n");
<BR> getchar();
<P> getfat(1, &diskinfo);
<BR>/* get drive information */
<P> printf("\nDrive A: is ");
<BR> switch((unsigned char) diskinfo.fi_fatid)
<BR> {
<BR> case 0xFD:
<BR> printf("360K low density\n");
<BR> break;
<P> case 0xF9:
<BR> printf("1.2 Meg high density\n");
<BR> break;
<P> default:
<BR> printf("unformatted\n");
<BR> flag = 1;
<BR> }
<P> if (!flag)
<BR> {
<BR> printf(" sectors per cluster %5d\n",
<BR> diskinfo.fi_sclus);
<BR> printf(" number of clusters
%5d\n",
<BR> diskinfo.fi_nclus);
<BR> printf(" bytes
per sector %5d\n",
<BR> diskinfo.fi_bysec);
<BR> }
<P> return 0;
<BR>}
<BR>
<BR>
<P>函數(shù)名: getfillpattern
<BR>功 能: 將用戶定義的填充模式拷貝到內(nèi)存中
<BR>用 法: void far getfillpattern(char far *upattern);
<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 maxx, maxy;
<BR> char pattern[8] = {0x00, 0x70, 0x20, 0x27, 0x25, 0x27,
0x04, 0x04};
<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> maxx = getmaxx();
<BR> maxy = getmaxy();
<BR> setcolor(getmaxcolor());
<P> /* select a user defined fill pattern */
<BR> setfillpattern(pattern, getmaxcolor());
<P> /* fill the screen with the pattern */
<BR> bar(0, 0, maxx, maxy);
<P> getch();
<P> /* get the current user defined fill pattern */
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -