分享
 
 
 

C语言库函数(G类字母)

王朝c/c++·作者佚名  2008-06-01
窄屏简体版  字體: |||超大  

函数名: getdate

功 能: 取DOS日期

用 法: void getdate(strUCt *dateblk);

程序例:

#include <dos.h>

#include <stdio.h>

int main(void)

{

struct date d;

getdate(&d);

printf("The current year is: %d\n",

d.da_year);

printf("The current day is: %d\n",

d.da_day);

printf("The current month is: %d\n",

d.da_mon);

return 0;

}

函数名: getdefaultpalette

功 能: 返回调色板定义结构

用 法: struct palettetype *far getdefaultpalette(void);

程序例:

#include <graphics.h>

#include <stdlib.h>

#include <stdio.h>

#include <conio.h>

int main(void)

{

/* request auto detection */

int gdriver = DETECT, gmode, errorcode;

int i;

/* structure for returning palette copy */

struct palettetype far *pal=(void *) 0;

/* initialize graphics and local variables */

initgraph(&gdriver, &gmode, "");

/* read result of initialization */

errorcode = graphresult();

/* an error occurred */

if (errorcode != grOk)

{

printf("Graphics error: %s\n",

grapherrormsg(errorcode));

printf("Press any key to halt:");

getch();

/* terminate with an error code */

exit(1);

}

setcolor(getmaxcolor());

/* return a pointer to the default palette */

pal = getdefaultpalette();

for (i=0; i<16; i++)

{

printf("colors[%d] = %d\n", i,

pal->colors[i]);

getch();

}

/* clean up */

getch();

closegraph();

return 0;

}

函数名: getdisk

功 能: 取当前磁盘驱动器号

用 法: int getdisk(void);

程序例:

#include <stdio.h>

#include <dir.h>

int main(void)

{

int disk;

disk = getdisk() + 'A';

printf("The current drive is: %c\n",

disk);

return 0;

}

函数名: getdrivername

功 能: 返回指向包含当前图形驱动程序名字的字符串指针

用 法: char *getdrivename(void);

程序例:

#include <graphics.h>

#include <stdlib.h>

#include <stdio.h>

#include <conio.h>

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\n",

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;

}

函数名: getdta

功 能: 取磁盘传输地址

用 法: char far *getdta(void);

程序例:

#include <dos.h>

#include <stdio.h>

int main(void)

{

char far *dta;

dta = getdta();

printf("The current disk transfer \

address is: %Fp\n", dta);

return 0;

}

函数名: getenv

功 能: 从环境中取字符串

用 法: char *getenv(char *envvar);

程序例:

#include <stdlib.h>

#include <stdio.h>

int main(void)

{

char *s;

s=getenv("COMSPEC"); /* get the comspec environment parameter */

printf("Command processor: %s\n",s); /* display comspec parameter */

return 0;

}

函数名: getfat, getfatd

功 能: 取文件分配表信息

用 法: void getfat(int drive, struct fatinfo *fatblkp);

程序例:

#include <stdio.h>

#include <dos.h>

int main(void)

{

struct fatinfo diSKINfo;

int flag = 0;

printf("Please insert disk in drive A\n");

getchar();

getfat(1, &diskinfo);

/* get drive information */

printf("\nDrive A: is ");

switch((unsigned char) diskinfo.fi_fatid)

{

case 0xFD:

printf("360K low density\n");

break;

case 0xF9:

printf("1.2 Meg high density\n");

break;

default:

printf("unformatted\n");

flag = 1;

}

if (!flag)

{

printf(" sectors per cluster %5d\n",

diskinfo.fi_sclus);

printf(" number of clusters %5d\n",

diskinfo.fi_nclus);

printf(" bytes per sector %5d\n",

diskinfo.fi_bysec);

}

return 0;

}

函数名: getfillpattern

功 能: 将用户定义的填充模式拷贝到内存中

用 法: void far getfillpattern(char far *upattern);

程序例:

#include <graphics.h>

#include <stdlib.h>

#include <stdio.h>

#include <conio.h>

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\n", 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;

}

函数名: getfillsettings

功 能: 取得有关当前填充模式和填充颜色的信息

用 法: void far getfillsettings(struct fillsettingstype far *fillinfo);

程序例:

#include <graphics.h>

#include <stdlib.h>

#include <stdio.h>

#include <conio.h>

/ 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\n", 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;

}

函数名: getftime

功 能: 取文件日期和时间

用 法: int getftime(int handle, struct ftime *ftimep);

程序例:

#include <stdio.h>

#include <io.h>

int main(void)

{

FILE *stream;

struct ftime ft;

if ((stream = fopen("TEST.$$$",

"wt")) == NULL)

{

fprintf(stderr,

"Cannot open output file.\n");

return 1;

}

getftime(fileno(stream), &ft);

printf("File time: %u:%u:%u\n",

ft.ft_hour, ft.ft_min,

ft.ft_tsec * 2);

printf("File date: %u/%u/%u\n",

ft.ft_month, ft.ft_day,

ft.ft_year+1980);

fclose(stream);

return 0;

}

函数名: getgraphmode

功 能: 返回当前图形模式

用 法: int far getgraphmode(void);

程序例:

#include <graphics.h>

#include <stdlib.h>

#include <stdio.h>

#include <conio.h>

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\n",

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;

}

函数名: getftime

功 能: 取文件日期和时间

用 法: int getftime(int handle, struct ftime *ftimep);

程序例:

#include <stdio.h>

#include <io.h>

int main(void)

{

FILE *stream;

struct ftime ft;

if ((stream = fopen("TEST.$$$",

"wt")) == NULL)

{

fprintf(stderr,

"Cannot open output file.\n");

return 1;

}

getftime(fileno(stream), &ft);

printf("File time: %u:%u:%u\n",

ft.ft_hour, ft.ft_min,

ft.ft_tsec * 2);

printf("File date: %u/%u/%u\n",

ft.ft_month, ft.ft_day,

ft.ft_year+1980);

fclose(stream);

return 0;

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有