Declaration: int getcurdir(int drive, char *directory);
Remarks:
getcurdir gets the name of the current working directory for the drive
indicated by drive.
drive ?Specifies a drive number (0 = default, 1 = A, etc.)
directory ?Points to an area of memory (of length MAXDIR) where the
?null-terminated directory name will be placed. The name
?does not contain the drive specification and does not begin
?with a backslash.
Return Value
?On success, returns 0
?On error, returns -1
char *current_directory(char *path)
{
strcpy(path, "X:\\"); /* 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);