|
Turbo C 2.0、Borland C++库函数及用例(39) /* fill string with form of response: X:\ */ path[0] = 'A' + getdisk(); /* replace X with current drive letter */ getcurdir(0, path+3); /* fill rest of string with current directory */ return(path); }int main(void) { char curdir[MAXPATH]; current_directory(curdir); printf("The current directory is %s\n", curdir); return 0; } 函数名: getcwd 功 能: 取当前工作目录 用 法: char *getcwd(char *buf, int n); 程序例:#include <stdio.h> #include <dir.h>int main(void) { char buffer[MAXPATH]; getcwd(buffer, MAXPATH); printf("The current directory is: %s\n", buffer); return 0; } 函数名: 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();
|