C語言庫函數(G類字母)" />

国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

[ 永遠的UNIX > C語言庫函數(G類字母)

2019-11-17 05:43:11
字體:
來源:轉載
供稿:網友

  函數名: getdate
功 能: 取DOS日期
用 法: void getdate(strUCt *dateblk);
程序例:

#include <dos.h>
#include <stdio.h>

int main(void)
{
struct date d;

getdate(&d);
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;
}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 遂宁市| 喜德县| 汤阴县| 长海县| 钦州市| 航空| 介休市| 金沙县| 大田县| 高安市| 宁都县| 将乐县| 高阳县| 三都| 全州县| 行唐县| 罗定市| 枣强县| 临朐县| 拜城县| 耒阳市| 安泽县| 新干县| 郴州市| 龙州县| 会理县| 射洪县| 巫山县| 英德市| 合江县| 雷州市| 利津县| 含山县| 利辛县| 安新县| 株洲县| 礼泉县| 富裕县| 洪江市| 平乐县| 若尔盖县|