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

📄 fg.htm

📁 turbo c
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<P>/* read result of initialization */<BR>&nbsp;&nbsp; errorcode = graphresult();<BR>/* an error occurred */<BR>&nbsp;&nbsp; if (errorcode != grOk)<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Graphics error: %s\n",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;grapherrormsg(errorcode));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Press any key to halt:");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getch();<BR>/* terminate with an error code */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(1);<BR>&nbsp;&nbsp; }<P>&nbsp;&nbsp; midx = getmaxx() / 2;<BR>&nbsp;&nbsp; midy = getmaxy() / 2;<BR>&nbsp;&nbsp; setcolor(getmaxcolor());<P>/* for centering text on the display */<BR>&nbsp;&nbsp; settextjustify(CENTER_TEXT, CENTER_TEXT);<P>/* get the current drawing color */<BR>&nbsp;&nbsp; color = getcolor();<P>/* convert color value into a string */<BR>&nbsp;&nbsp; itoa(color, colname, 10);<BR>&nbsp;&nbsp; strcat(colname,<BR>&nbsp;&nbsp; " is the current drawing color.");<P>/* display a message */<BR>&nbsp;&nbsp; outtextxy(midx, midy, colname);<P>/* clean up */<BR>&nbsp;&nbsp; getch();<BR>&nbsp;&nbsp; closegraph();<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: getcurdir<BR>功&nbsp; 能: 取指定驱动器的当前目录<BR>用&nbsp; 法: int getcurdir(int drive, char *direc);<BR>程序例:<P>#include &lt;dir.h><BR>#include &lt;stdio.h><BR>#include &lt;string.h><P>char *current_directory(char *path)<BR>{<BR>&nbsp;&nbsp; strcpy(path, "X:\\");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*fill string with form of response: X:\ */<BR>&nbsp;&nbsp; path[0] = 'A' + getdisk();&nbsp;&nbsp;&nbsp; /* replaceX with current drive letter */<BR>&nbsp;&nbsp; getcurdir(0, path+3);&nbsp; /* fill rest of string withcurrent directory */<BR>&nbsp;&nbsp; return(path);<BR>}<P>int main(void)<BR>{<BR>&nbsp;&nbsp; char curdir[MAXPATH];<P>&nbsp;&nbsp; current_directory(curdir);<BR>&nbsp;&nbsp; printf("The current directory is %s\n", curdir);<P>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: getcwd<BR>功&nbsp; 能: 取当前工作目录<BR>用&nbsp; 法: char *getcwd(char *buf, int n);<BR>程序例:<P>#include &lt;stdio.h><BR>#include &lt;dir.h><P>int main(void)<BR>{<BR>&nbsp;&nbsp; char buffer[MAXPATH];<P>&nbsp;&nbsp; getcwd(buffer, MAXPATH);<BR>&nbsp;&nbsp; printf("The current directory is: %s\n", buffer);<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: getdate<BR>功&nbsp; 能: 取DOS日期<BR>用&nbsp; 法: void getdate(struct *dateblk);<BR>程序例:<P>#include &lt;dos.h><BR>#include &lt;stdio.h><P>int main(void)<BR>{<BR>&nbsp;&nbsp; struct date d;<P>&nbsp;&nbsp; getdate(&amp;d);<BR>&nbsp;&nbsp; printf("The current year is: %d\n",<BR>&nbsp;&nbsp; d.da_year);<BR>&nbsp;&nbsp; printf("The current day is: %d\n",<BR>&nbsp;&nbsp; d.da_day);<BR>&nbsp;&nbsp; printf("The current month is: %d\n",<BR>&nbsp;&nbsp; d.da_mon);<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: getdefaultpalette<BR>功&nbsp; 能: 返回调色板定义结构<BR>用&nbsp; 法: struct palettetype *far getdefaultpalette(void);<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>/* request auto detection */<BR>&nbsp;&nbsp; int gdriver = DETECT, gmode, errorcode;<BR>&nbsp;&nbsp; int i;<P>/* structure for returning palette copy */<BR>&nbsp;&nbsp; struct palettetype far *pal=(void *) 0;<P>/* initialize graphics and local variables */<BR>&nbsp;&nbsp; initgraph(&amp;gdriver, &amp;gmode, "");<P>/* read result of initialization */<BR>&nbsp;&nbsp; errorcode = graphresult();<BR>/* an error occurred */<BR>&nbsp;&nbsp; if (errorcode != grOk)<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Graphics error: %s\n",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;grapherrormsg(errorcode));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Press any key to halt:");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getch();<BR>/* terminate with an error code */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(1);<BR>&nbsp;&nbsp; }<P>&nbsp;&nbsp; setcolor(getmaxcolor());<P>/* return a pointer to the default palette */<BR>&nbsp;&nbsp; pal = getdefaultpalette();<P>&nbsp;&nbsp; for (i=0; i&lt;16; i++)<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("colors[%d] = %d\n", i,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pal->colors[i]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getch();<BR>&nbsp;&nbsp; }<P>/* clean up */<BR>&nbsp;&nbsp; getch();<BR>&nbsp;&nbsp; closegraph();<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: getdisk<BR>功&nbsp; 能: 取当前磁盘驱动器号<BR>用&nbsp; 法: int getdisk(void);<BR>程序例:<P>#include &lt;stdio.h><BR>#include &lt;dir.h><P>int main(void)<BR>{<BR>&nbsp;&nbsp; int disk;<P>&nbsp;&nbsp; disk = getdisk() + 'A';<BR>&nbsp;&nbsp; printf("The current drive is: %c\n",<BR>&nbsp;&nbsp;&nbsp; disk);<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<P>函数名: getdrivername<BR>功&nbsp; 能: 返回指向包含当前图形驱动程序名字的字符串指针<BR>用&nbsp; 法: char *getdrivename(void);<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>/* request auto detection */<BR>&nbsp;&nbsp; int gdriver = DETECT, gmode, errorcode;<P>/* stores the device driver name */<BR>&nbsp;&nbsp; char *drivername;<P>/* initialize graphics and local variables */<BR>&nbsp;&nbsp; initgraph(&amp;gdriver, &amp;gmode, "");<P>/* read result of initialization */<BR>&nbsp;&nbsp; errorcode = graphresult();<BR>/* an error occurred */<BR>&nbsp;&nbsp; if (errorcode != grOk)<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Graphics error: %s\n",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;grapherrormsg(errorcode));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Press any key to halt:");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getch();<BR>/* terminate with an error code */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(1);<BR>&nbsp;&nbsp; }<P>&nbsp;&nbsp; setcolor(getmaxcolor());<P>/* get name of the device driver in use */<BR>&nbsp;&nbsp; drivername = getdrivername();<P>/* for centering text on the screen */<BR>&nbsp;&nbsp; settextjustify(CENTER_TEXT, CENTER_TEXT);<P>/* output the name of the driver */<BR>&nbsp;&nbsp; outtextxy(getmaxx() / 2, getmaxy() / 2,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; drivername);<P>/* clean up */<BR>&nbsp;&nbsp; getch();<BR>&nbsp;&nbsp; closegraph();<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: getdta<BR>功&nbsp; 能: 取磁盘传输地址<BR>用&nbsp; 法: char far *getdta(void);<BR>程序例:<P>#include &lt;dos.h><BR>#include &lt;stdio.h><P>int main(void)<BR>{<BR>&nbsp;&nbsp; char far *dta;<P>&nbsp;&nbsp; dta = getdta();<BR>&nbsp;&nbsp; printf("The current disk transfer \<BR>&nbsp;&nbsp; address is: %Fp\n", dta);<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: getenv<BR>功&nbsp; 能: 从环境中取字符串<BR>用&nbsp; 法: char *getenv(char *envvar);<BR>程序例:<P>#include &lt;stdlib.h><BR>#include &lt;stdio.h><BR>&nbsp;<P>int main(void)<BR>{<BR>&nbsp;&nbsp;&nbsp; char *s;<P>&nbsp;&nbsp;&nbsp; s=getenv("COMSPEC");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* get the comspec environment parameter */<BR>&nbsp;&nbsp;&nbsp; printf("Command processor: %s\n",s);&nbsp;&nbsp;/* display comspec parameter */<P>&nbsp;&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<P>函数名: getfat, getfatd<BR>功&nbsp; 能: 取文件分配表信息<BR>用&nbsp; 法: void getfat(int drive, struct fatinfo *fatblkp);<BR>程序例:<P>#include &lt;stdio.h><BR>#include &lt;dos.h><P>int main(void)<BR>{<BR>&nbsp;&nbsp; struct fatinfo diskinfo;<BR>&nbsp;&nbsp; int flag = 0;<P>&nbsp;&nbsp; printf("Please insert disk in drive A\n");<BR>&nbsp;&nbsp; getchar();<P>&nbsp;&nbsp; getfat(1, &amp;diskinfo);<BR>/* get drive information */<P>&nbsp;&nbsp; printf("\nDrive A: is ");<BR>&nbsp;&nbsp; switch((unsigned char) diskinfo.fi_fatid)<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 0xFD:<BR>&nbsp;printf("360K low density\n");<BR>&nbsp;break;<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 0xF9:<BR>&nbsp;printf("1.2 Meg high density\n");<BR>&nbsp;break;<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default:<BR>&nbsp;printf("unformatted\n");<BR>&nbsp;flag = 1;<BR>&nbsp;&nbsp; }<P>&nbsp;&nbsp; if (!flag)<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("&nbsp; sectors per cluster %5d\n",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; diskinfo.fi_sclus);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("&nbsp;&nbsp; number of clusters%5d\n",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; diskinfo.fi_nclus);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("&nbsp;&nbsp;&nbsp;&nbsp; bytesper sector %5d\n",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; diskinfo.fi_bysec);<BR>&nbsp;&nbsp; }<P>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: getfillpattern<BR>功&nbsp; 能: 将用户定义的填充模式拷贝到内存中<BR>用&nbsp; 法: void far getfillpattern(char far *upattern);<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 maxx, maxy;<BR>&nbsp;&nbsp; char pattern[8] = {0x00, 0x70, 0x20, 0x27, 0x25, 0x27,0x04, 0x04};<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; maxx = getmaxx();<BR>&nbsp;&nbsp; maxy = getmaxy();<BR>&nbsp;&nbsp; setcolor(getmaxcolor());<P>&nbsp;&nbsp; /* select a user defined fill pattern */<BR>&nbsp;&nbsp; setfillpattern(pattern, getmaxcolor());<P>&nbsp;&nbsp; /* fill the screen with the pattern */<BR>&nbsp;&nbsp; bar(0, 0, maxx, maxy);<P>&nbsp;&nbsp; getch();<P>&nbsp;&nbsp; /* get the current user defined fill pattern */<BR>&nbsp;&nbsp; getfillpattern(pattern);<P>&nbsp;&nbsp; /* alter the pattern we grabbed */<BR>&nbsp;&nbsp; pattern[4] -= 1;<BR>&nbsp;&nbsp; pattern[5] -= 3;<BR>&nbsp;&nbsp; pattern[6] += 3;<BR>&nbsp;&nbsp; pattern[7] -= 4;<P>&nbsp;&nbsp; /* select our new pattern */<BR>&nbsp;&nbsp; setfillpattern(pattern, getmaxcolor());<P>&nbsp;&nbsp; /* fill the screen with the new pattern */<BR>&nbsp;&nbsp; bar(0, 0, maxx, maxy);<P>&nbsp;&nbsp; /* clean up */<BR>&nbsp;&nbsp; getch();<BR>&nbsp;&nbsp; closegraph();<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: getfillsettings<BR>功&nbsp; 能: 取得有关当前填充模式和填充颜色的信息

⌨️ 快捷键说明

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