📄 fg.htm
字号:
<p> return 0; <br>
} <br>
<br>
</p>
<p>函数名: getche <br>
功 能: 从控制台取字符(带回显) <br>
用 法: int getche(void); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
char ch; </p>
<p> printf("Input a character:"); <br>
ch = getche(); <br>
printf("\nYou input a '%c'\n", ch); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: getcolor <br>
功 能: 返回当前画线颜色 <br>
用 法: int far getcolor(void); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <string.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<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>
<p>/* initialize graphics and local variables */ <br>
initgraph(&gdriver, &gmode, ""); </p>
<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>
<p> midx = getmaxx() / 2; <br>
midy = getmaxy() / 2; <br>
setcolor(getmaxcolor()); </p>
<p>/* for centering text on the display */ <br>
settextjustify(CENTER_TEXT, CENTER_TEXT); </p>
<p>/* get the current drawing color */ <br>
color = getcolor(); </p>
<p>/* convert color value into a string */ <br>
itoa(color, colname, 10); <br>
strcat(colname, <br>
" is the current drawing color."); </p>
<p>/* display a message */ <br>
outtextxy(midx, midy, colname); </p>
<p>/* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: getcurdir <br>
功 能: 取指定驱动器的当前目录 <br>
用 法: int getcurdir(int drive, char *direc); <br>
程序例: </p>
<p>#include <dir.h> <br>
#include <stdio.h> <br>
#include <string.h> </p>
<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>
<p>int main(void) <br>
{ <br>
char curdir[MAXPATH]; </p>
<p> current_directory(curdir); <br>
printf("The current directory is %s\n",
curdir); </p>
<p> return 0; <br>
} <br>
<br>
</p>
<p>函数名: getcwd <br>
功 能: 取当前工作目录 <br>
用 法: char *getcwd(char *buf, int n); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <dir.h> </p>
<p>int main(void) <br>
{ <br>
char buffer[MAXPATH]; </p>
<p> getcwd(buffer, MAXPATH); <br>
printf("The current directory is: %s\n",
buffer); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: getdate <br>
功 能: 取DOS日期 <br>
用 法: void getdate(struct *dateblk); <br>
程序例: </p>
<p>#include <dos.h> <br>
#include <stdio.h> </p>
<p>int main(void) <br>
{ <br>
struct date d; </p>
<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>
<p>函数名: getdefaultpalette <br>
功 能: 返回调色板定义结构 <br>
用 法: struct palettetype *far getdefaultpalette(void); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; <br>
int i; </p>
<p>/* structure for returning palette copy */ <br>
struct palettetype far *pal=(void *) 0; </p>
<p>/* initialize graphics and local variables */ <br>
initgraph(&gdriver, &gmode, ""); </p>
<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>
<p> setcolor(getmaxcolor()); </p>
<p>/* return a pointer to the default palette */ <br>
pal = getdefaultpalette(); </p>
<p> for (i=0; i<16; i++) <br>
{ <br>
printf("colors[%d] =
%d\n", i, <br>
pal->colors[i]); <br>
getch(); <br>
} </p>
<p>/* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: getdisk <br>
功 能: 取当前磁盘驱动器号 <br>
用 法: int getdisk(void); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <dir.h> </p>
<p>int main(void) <br>
{ <br>
int disk; </p>
<p> disk = getdisk() + 'A'; <br>
printf("The current drive is: %c\n", <br>
disk); <br>
return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: getdrivername <br>
功 能:
返回指向包含当前图形驱动程序名字的字符串指针
<br>
用 法: char *getdrivename(void); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; </p>
<p>/* stores the device driver name */ <br>
char *drivername; </p>
<p>/* initialize graphics and local variables */ <br>
initgraph(&gdriver, &gmode, ""); </p>
<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>
<p> setcolor(getmaxcolor()); </p>
<p>/* get name of the device driver in use */ <br>
drivername = getdrivername(); </p>
<p>/* for centering text on the screen */ <br>
settextjustify(CENTER_TEXT, CENTER_TEXT); </p>
<p>/* output the name of the driver */ <br>
outtextxy(getmaxx() / 2, getmaxy() / 2, <br>
drivername); </p>
<p>/* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: getdta <br>
功 能: 取磁盘传输地址 <br>
用 法: char far *getdta(void); <br>
程序例: </p>
<p>#include <dos.h> <br>
#include <stdio.h> </p>
<p>int main(void) <br>
{ <br>
char far *dta; </p>
<p> dta = getdta(); <br>
printf("The current disk transfer \ <br>
address is: %Fp\n", dta); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: getenv <br>
功 能: 从环境中取字符串 <br>
用 法: char *getenv(char *envvar); <br>
程序例: </p>
<p>#include <stdlib.h> <br>
#include <stdio.h> <br>
</p>
<p>int main(void) <br>
{ <br>
char *s; </p>
<p> s=getenv("COMSPEC");
/* get the comspec environment parameter */ <br>
printf("Command processor: %s\n",s);
/* display comspec parameter */ </p>
<p> return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: getfat, getfatd <br>
功 能: 取文件分配表信息 <br>
用 法: void getfat(int drive, struct fatinfo *fatblkp); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <dos.h> </p>
<p>int main(void) <br>
{ <br>
struct fatinfo diskinfo; <br>
int flag = 0; </p>
<p> printf("Please insert disk in drive
A\n"); <br>
getchar(); </p>
<p> getfat(1, &diskinfo); <br>
/* get drive information */ </p>
<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>
<p> case 0xF9: <br>
printf("1.2 Meg high density\n"); <br>
break; </p>
<p> default: <br>
printf("unformatted\n"); <br>
flag = 1; <br>
} </p>
<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("
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -