C语言库函数G类字母2.docx

上传人:b****6 文档编号:7844122 上传时间:2023-01-26 格式:DOCX 页数:11 大小:16.93KB
下载 相关 举报
C语言库函数G类字母2.docx_第1页
第1页 / 共11页
C语言库函数G类字母2.docx_第2页
第2页 / 共11页
C语言库函数G类字母2.docx_第3页
第3页 / 共11页
C语言库函数G类字母2.docx_第4页
第4页 / 共11页
C语言库函数G类字母2.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

C语言库函数G类字母2.docx

《C语言库函数G类字母2.docx》由会员分享,可在线阅读,更多相关《C语言库函数G类字母2.docx(11页珍藏版)》请在冰豆网上搜索。

C语言库函数G类字母2.docx

C语言库函数G类字母2

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

本文出自:

作者:

(2001-07-2808:

05:

00)

函数名:

getdate

功能:

取DOS日期

用法:

voidgetdate(struct*dateblk);

程序例:

#include

#include

intmain(void)

{

structdated;

getdate(&d);

printf("Thecurrentyearis:

%d\n",

d.da_year);

printf("Thecurrentdayis:

%d\n",

d.da_day);

printf("Thecurrentmonthis:

%d\n",

d.da_mon);

return0;

}

函数名:

getdefaultpalette

功能:

返回调色板定义结构

用法:

structpalettetype*fargetdefaultpalette(void);

程序例:

#include

#include

#include

#include

intmain(void)

{

/*requestautodetection*/

intgdriver=DETECT,gmode,errorcode;

inti;

/*structureforreturningpalettecopy*/

structpalettetypefar*pal=(void*)0;

/*initializegraphicsandlocalvariables*/

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

/*readresultofinitialization*/

errorcode=graphresult();

/*anerroroccurred*/

if(errorcode!

=grOk)

{

printf("Graphicserror:

%s\n",

grapherrormsg(errorcode));

printf("Pressanykeytohalt:

");

getch();

/*terminatewithanerrorcode*/

exit

(1);

}

setcolor(getmaxcolor());

/*returnapointertothedefaultpalette*/

pal=getdefaultpalette();

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

{

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

pal->colors[i]);

getch();

}

/*cleanup*/

getch();

closegraph();

return0;

}

函数名:

getdisk

功能:

取当前磁盘驱动器号

用法:

intgetdisk(void);

程序例:

#include

#include

intmain(void)

{

intdisk;

disk=getdisk()+'A';

printf("Thecurrentdriveis:

%c\n",

disk);

return0;

}

函数名:

getdrivername

功能:

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

用法:

char*getdrivename(void);

程序例:

#include

#include

#include

#include

intmain(void)

{

/*requestautodetection*/

intgdriver=DETECT,gmode,errorcode;

/*storesthedevicedrivername*/

char*drivername;

/*initializegraphicsandlocalvariables*/

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

/*readresultofinitialization*/

errorcode=graphresult();

/*anerroroccurred*/

if(errorcode!

=grOk)

{

printf("Graphicserror:

%s\n",

grapherrormsg(errorcode));

printf("Pressanykeytohalt:

");

getch();

/*terminatewithanerrorcode*/

exit

(1);

}

setcolor(getmaxcolor());

/*getnameofthedevicedriverinuse*/

drivername=getdrivername();

/*forcenteringtextonthescreen*/

settextjustify(CENTER_TEXT,CENTER_TEXT);

/*outputthenameofthedriver*/

outtextxy(getmaxx()/2,getmaxy()/2,

drivername);

/*cleanup*/

getch();

closegraph();

return0;

}

函数名:

getdta

功能:

取磁盘传输地址

用法:

charfar*getdta(void);

程序例:

#include

#include

intmain(void)

{

charfar*dta;

dta=getdta();

printf("Thecurrentdisktransfer\

addressis:

%Fp\n",dta);

return0;

}

函数名:

getenv

功能:

从环境中取字符串

用法:

char*getenv(char*envvar);

程序例:

#include

#include

intmain(void)

{

char*s;

s=getenv("COMSPEC");/*getthecomspecenvironmentparameter*/

printf("Commandprocessor:

%s\n",s);/*displaycomspecparameter*/

return0;

}

函数名:

getfat,getfatd

功能:

取文件分配表信息

用法:

voidgetfat(intdrive,structfatinfo*fatblkp);

程序例:

#include

#include

intmain(void)

{

structfatinfodiskinfo;

intflag=0;

printf("PleaseinsertdiskindriveA\n");

getchar();

getfat(1,&diskinfo);

/*getdriveinformation*/

printf("\nDriveA:

is");

switch((unsignedchar)diskinfo.fi_fatid)

{

case0xFD:

printf("360Klowdensity\n");

break;

case0xF9:

printf("1.2Meghighdensity\n");

break;

default:

printf("unformatted\n");

flag=1;

}

if(!

flag)

{

printf("sectorspercluster%5d\n",

diskinfo.fi_sclus);

printf("numberofclusters%5d\n",

diskinfo.fi_nclus);

printf("bytespersector%5d\n",

diskinfo.fi_bysec);

}

return0;

}

函数名:

getfillpattern

功能:

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

用法:

voidfargetfillpattern(charfar*upattern);

程序例:

#include

#include

#include

#include

intmain(void)

{

/*requestautodetection*/

intgdriver=DETECT,gmode,errorcode;

intmaxx,maxy;

charpattern[8]={0x00,0x70,0x20,0x27,0x25,0x27,0x04,0x04};

/*initializegraphicsandlocalvariables*/

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

/*readresultofinitialization*/

errorcode=graphresult();

if(errorcode!

=grOk)/*anerroroccurred*/

{

printf("Graphicserror:

%s\n",grapherrormsg(errorcode));

printf("Pressanykeytohalt:

");

getch();

exit

(1);/*terminatewithanerrorcode*/

}

maxx=getmaxx();

maxy=getmaxy();

setcolor(getmaxcolor());

/*selectauserdefinedfillpattern*/

setfillpattern(pattern,getmaxcolor());

/*fillthescreenwiththepattern*/

bar(0,0,maxx,maxy);

getch();

/*getthecurrentuserdefinedfillpattern*/

getfillpattern(pattern);

/*alterthepatternwegrabbed*/

pattern[4]-=1;

pattern[5]-=3;

pattern[6]+=3;

pattern[7]-=4;

/*selectournewpattern*/

setfillpattern(pattern,getmaxcolor());

/*fillthescreenwiththenewpattern*/

bar(0,0,maxx,maxy);

/*cleanup*/

getch();

closegraph();

return0;

}

函数名:

getfillsettings

功能:

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

用法:

voidfargetfillsettings(structfillsettingstypefar*fillinfo);

程序例:

#include

#include

#include

#include

/thenamesofthefillstylessupported*/

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"

};

intmain(void)

{

/*requestautodetection*/

intgdriver=DETECT,gmode,errorcode;

structfillsettingstypefillinfo;

intmidx,midy;

charpatstr[40],colstr[40];

/*initializegraphicsandlocalvariables*/

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

/*readresultofinitialization*/

errorcode=graphresult();

if(errorcode!

=grOk)/*anerroroccurred*/

{

printf("Graphicserror:

%s\n",grapherrormsg(errorcode));

printf("Pressanykeytohalt:

");

getch();

exit

(1);/*terminatewithanerrorcode*/

}

midx=getmaxx()/2;

midy=getmaxy()/2;

/*getinformationaboutcurrentfillpatternandcolor*/

getfillsettings(&fillinfo);

/*convertfillinformationintostrings*/

sprintf(patstr,"%sisthefillstyle.",fname[fillinfo.pattern]);

sprintf(colstr,"%disthefillcolor.",fillinfo.color);

/*displaytheinformation*/

settextjustify(CENTER_TEXT,CENTER_TEXT);

outtextxy(midx,midy,patstr);

outtextxy(midx,midy+2*textheight("W"),colstr);

/*cleanup*/

getch();

closegraph();

return0;

}

函数名:

getftime

功能:

取文件日期和时间

用法:

intgetftime(inthandle,structftime*ftimep);

程序例:

#include

#include

intmain(void)

{

FILE*stream;

structftimeft;

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

"wt"))==NULL)

{

fprintf(stderr,

"Cannotopenoutputfile.\n");

return1;

}

getftime(fileno(stream),&ft);

printf("Filetime:

%u:

%u:

%u\n",

ft.ft_hour,ft.ft_min,

ft.ft_tsec*2);

printf("Filedate:

%u/%u/%u\n",

ft.ft_month,ft.ft_day,

ft.ft_year+1980);

fclose(stream);

return0;

}

函数名:

getgraphmode

功能:

返回当前图形模式

用法:

intfargetgraphmode(void);

程序例:

#include

#include

#include

#include

intmain(void)

{

/*requestautodetection*/

intgdriver=DETECT,gmode,errorcode;

intmidx,midy,mode;

charnumname[80],modename[80];

/*initializegraphicsandlocalvariables*/

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

/*readresultofinitialization*/

errorcode=graphresult();

/*anerroroccurred*/

if(errorcode!

=grOk)

{

printf("Graphicserror:

%s\n",

grapherrormsg(errorcode));

printf("Pressanykeytohalt:

");

getch();

/*terminatewithanerrorcode*/

exit

(1);

}

midx=getmaxx()/2;

midy=getmaxy()/2;

/*getmodenumberandnamestrings*/

mode=getgraphmode();

sprintf(numname,

"%disthecurrentmodenumber.",

mode);

sprintf(modename,

"%sisthecurrentgraphicsmode",

getmodename(mode));

/*displaytheinformation*/

settextjustify(CENTER_TEXT,CENTER_TEXT);

outtextxy(midx,midy,numname);

outtextxy(midx,midy+2*textheight("W"),

modename);

/*cleanup*/

getch();

closegraph();

return0;

}

函数名:

getftime

功能:

取文件日期和时间

用法:

intgetftime(inthandle,structftime*ftimep);

程序例:

#include

#include

intmain(void)

{

FILE*stream;

structftimeft;

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

"wt"))==NULL)

{

fprintf(stderr,

"Cannotopenoutputfile.\n");

return1;

}

getftime(fileno(stream),&ft);

printf("Filetime:

%u:

%u:

%u\n",

ft.ft_hour,ft.ft_min,

ft.ft_tsec*2);

printf("Filedate:

%u/%u/%u\n",

ft.ft_month,ft.ft_day,

ft.ft_year+1980);

fclose(stream);

return0;

}

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 经管营销 > 经济市场

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1