找回密码

碧海潮声大学生网

楼主: 墙角野猫
打印 上一主题 下一主题

c语言函数大全

[复制链接]
91#
 楼主| 发表于 2006-7-12 23:32 | 只看该作者
函数名: getdisk
功 能: 取当前磁盘驱动器号
用 法: int getdisk(void);
程序例:
#include
#include
int main(void)
{
int disk;
disk = getdisk() + 'A';
printf("The current drive is: %c
",
disk);
return 0;
}
92#
 楼主| 发表于 2006-7-12 23:32 | 只看该作者
函数名: getdrivername
功 能: 返回指向包含当前图形驱动程序名字的字符串指针
用 法: char *getdrivename(void);
程序例:
#include
#include
#include
#include
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
/* stores the device driver name */
char *drivername;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
/* an error occurred */
if (errorcode != grOk)
{
printf("Graphics error: %s
",
grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
/* terminate with an error code */
exit(1);
}
setcolor(getmaxcolor());
/* get name of the device driver in use */
drivername = getdrivername();
/* for centering text on the screen */
settextjustify(CENTER_TEXT, CENTER_TEXT);
/* output the name of the driver */
outtextxy(getmaxx() / 2, getmaxy() / 2,
drivername);
/* clean up */
getch();
closegraph();
return 0;
}
93#
 楼主| 发表于 2006-7-12 23:32 | 只看该作者
函数名: getdta
功 能: 取磁盘传输地址
用 法: char far *getdta(void);
程序例:
#include
#include
int main(void)
{
char far *dta;
dta = getdta();
printf("The current disk transfer \
address is: %Fp
", dta);
return 0;
}
94#
 楼主| 发表于 2006-7-12 23:33 | 只看该作者
函数名: getenv
功 能: 从环境中取字符串
用 法: char *getenv(char *envvar);
程序例:
#include
#include

int main(void)
{
char *s;
s=getenv("COMSPEC"); /* get the comspec environment parameter */
printf("Command processor: %s
",s); /* display comspec parameter */
return 0;
}
95#
 楼主| 发表于 2006-7-12 23:34 | 只看该作者
函数名: getfat, getfatd
功 能: 取文件分配表信息
用 法: void getfat(int drive, struct fatinfo *fatblkp);
程序例:
#include
#include
int main(void)
{
struct fatinfo diskinfo;
int flag = 0;
printf("Please insert disk in drive A
");
getchar();
getfat(1, &diskinfo);
/* get drive information */
printf("
Drive A: is ");
switch((unsigned char) diskinfo.fi_fatid)
{
case 0xFD:
printf("360K low density
");
break;
case 0xF9:
printf("1.2 Meg high density
");
break;
default:
printf("unformatted
");
flag = 1;
}
if (!flag)
{
printf(" sectors per cluster %5d
",
diskinfo.fi_sclus);
printf(" number of clusters %5d
",
diskinfo.fi_nclus);
printf(" bytes per sector %5d
",
diskinfo.fi_bysec);
}
return 0;
}
96#
 楼主| 发表于 2006-7-12 23:34 | 只看该作者
函数名: getfillpattern
功 能: 将用户定义的填充模式拷贝到内存中
用 法: void far getfillpattern(char far *upattern);
程序例:
#include
#include
#include
#include
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int maxx, maxy;
char pattern[8] = {0x00, 0x70, 0x20, 0x27, 0x25, 0x27, 0x04, 0x04};
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s
", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
maxx = getmaxx();
maxy = getmaxy();
setcolor(getmaxcolor());
/* select a user defined fill pattern */
setfillpattern(pattern, getmaxcolor());
/* fill the screen with the pattern */
bar(0, 0, maxx, maxy);
getch();
/* get the current user defined fill pattern */
getfillpattern(pattern);
/* alter the pattern we grabbed */
pattern[4] -= 1;
pattern[5] -= 3;
pattern[6] += 3;
pattern[7] -= 4;
/* select our new pattern */
setfillpattern(pattern, getmaxcolor());
/* fill the screen with the new pattern */
bar(0, 0, maxx, maxy);
/* clean up */
getch();
closegraph();
return 0;
}
97#
 楼主| 发表于 2006-7-12 23:34 | 只看该作者
函数名: getfillsettings
功 能: 取得有关当前填充模式和填充颜色的信息
用 法: void far getfillsettings(struct fillsettingstype far *fillinfo);
程序例:
#include
#include
#include
#include
/ the names of the fill styles supported */
char *fname[] = { "EMPTY_FILL",
"SOLID_FILL",
"LINE_FILL",
"LTSLASH_FILL",
"SLASH_FILL",
"BKSLASH_FILL",
"LTBKSLASH_FILL",
"HATCH_FILL",
"XHATCH_FILL",
"INTERLEAVE_FILL",
"WIDE_DOT_FILL",
"CLOSE_DOT_FILL",
"USER_FILL"
};
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
struct fillsettingstype fillinfo;
int midx, midy;
char patstr[40], colstr[40];
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s
", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
/* get information about current fill pattern and color */
getfillsettings(&fillinfo);
/* convert fill information into strings */
sprintf(patstr, "%s is the fill style.", fname[fillinfo.pattern]);
sprintf(colstr, "%d is the fill color.", fillinfo.color);
/* display the information */
settextjustify(CENTER_TEXT, CENTER_TEXT);
outtextxy(midx, midy, patstr);
outtextxy(midx, midy+2*textheight("W"), colstr);
/* clean up */
getch();
closegraph();
return 0;
}
98#
 楼主| 发表于 2006-7-12 23:35 | 只看该作者
函数名: getftime
功 能: 取文件日期和时间
用 法: int getftime(int handle, struct ftime *ftimep);
程序例:
#include
#include
int main(void)
{
FILE *stream;
struct ftime ft;
if ((stream = fopen("TEST.$$$",
"wt")) == NULL)
{
fprintf(stderr,
"Cannot open output file.
");
return 1;
}
getftime(fileno(stream), &ft);
printf("File time: %u:%u:%u
",
ft.ft_hour, ft.ft_min,
ft.ft_tsec * 2);
printf("File date: %u/%u/%u
",
ft.ft_month, ft.ft_day,
ft.ft_year+1980);
fclose(stream);
return 0;
}
99#
 楼主| 发表于 2006-7-12 23:35 | 只看该作者
函数名: getgraphmode
功 能: 返回当前图形模式
用 法: int far getgraphmode(void);
程序例:
#include
#include
#include
#include
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy, mode;
char numname[80], modename[80];
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
/* an error occurred */
if (errorcode != grOk)
{
printf("Graphics error: %s
",
grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
/* terminate with an error code */
exit(1);
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
/* get mode number and name strings */
mode = getgraphmode();
sprintf(numname,
"%d is the current mode number.",
mode);
sprintf(modename,
"%s is the current graphics mode",
getmodename(mode));
/* display the information */
settextjustify(CENTER_TEXT, CENTER_TEXT);
outtextxy(midx, midy, numname);
outtextxy(midx, midy+2*textheight("W"),
modename);
/* clean up */
getch();
closegraph();
return 0;
}
100#
 楼主| 发表于 2006-7-12 23:35 | 只看该作者
函数名: getftime
功 能: 取文件日期和时间
用 法: int getftime(int handle, struct ftime *ftimep);
程序例:
#include
#include
int main(void)
{
FILE *stream;
struct ftime ft;
if ((stream = fopen("TEST.$$$",
"wt")) == NULL)
{
fprintf(stderr,
"Cannot open output file.
");
return 1;
}
getftime(fileno(stream), &ft);
printf("File time: %u:%u:%u
",
ft.ft_hour, ft.ft_min,
ft.ft_tsec * 2);
printf("File date: %u/%u/%u
",
ft.ft_month, ft.ft_day,
ft.ft_year+1980);
fclose(stream);
return 0;
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋| 碧海潮声大学生网  

Copyright © 2001-2013 Comsenz Inc.   All Rights Reserved.

Powered by Discuz! X3.2( 浙ICP备11026473号 )

快速回复 返回顶部 返回列表