|
Turbo C 2.0、Borland C++库函数及用例(41) #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();
|