📄 fg.htm
字号:
<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>函数名: getcurdir<BR>功 能: 取指定驱动器的当前目录<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(); /* replaceX with current drive letter */<BR> getcurdir(0, path+3); /* fill rest of string withcurrent 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>函数名: getcwd<BR>功 能: 取当前工作目录<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>函数名: 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>函数名: getdefaultpalette<BR>功 能: 返回调色板定义结构<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>函数名: getdisk<BR>功 能: 取当前磁盘驱动器号<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>函数名: getdrivername<BR>功 能: 返回指向包含当前图形驱动程序名字的字符串指针<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>函数名: getdta<BR>功 能: 取磁盘传输地址<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>函数名: getenv<BR>功 能: 从环境中取字符串<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>函数名: 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(" bytesper sector %5d\n",<BR> diskinfo.fi_bysec);<BR> }<P> return 0;<BR>}<BR> <BR> <P>函数名: getfillpattern<BR>功 能: 将用户定义的填充模式拷贝到内存中<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 errorcode */<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 */<BR> getfillpattern(pattern);<P> /* alter the pattern we grabbed */<BR> pattern[4] -= 1;<BR> pattern[5] -= 3;<BR> pattern[6] += 3;<BR> pattern[7] -= 4;<P> /* select our new pattern */<BR> setfillpattern(pattern, getmaxcolor());<P> /* fill the screen with the new pattern */<BR> bar(0, 0, maxx, maxy);<P> /* clean up */<BR> getch();<BR> closegraph();<BR> return 0;<BR>}<BR> <BR> <P>函数名: getfillsettings<BR>功 能: 取得有关当前填充模式和填充颜色的信息
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -