_getdcwd
Gets current directory for specified drive.
Defined in header <direct.h>
Syntax
#include <direct.h>
char * _getdcwd(int drive, char *buffer,intbuflen);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ |
Remarks
_getdcwd gets the full path name of the working directory of the specified drive (including the drive name), up to buflen bytes long, and stores it in buffer. If the full path name length (including the null-terminator) is longer than buflen, an error occurs. The drive is 0 for the default drive, 1=A, 2=B, etc.
If buffer is NULL, _getdcwd will allocate a buffer at least buflen bytes long. You can later free the allocated buffer by passing the _getdcwd return value to the free function.
Return value
If successful, _getdcwd returns a pointer to the buffer containing the current directory for the specified drive. Otherwise it returns NULL, and sets the global variable errno to one of the following:
| ENOMEM | Not enough memory to allocate a buffer (buffer is NULL) |
ERANGE Directory name longer than buflen {buffer is not NULL)
See also
Example
#include <direct.h>
#include <stdio.h>
void mainO
char buf[65];
if (_getdcwd(3, buf, sizeof(buf)) == NULL)
perror("Unable to get current directory of drive C");
else
printf("Current directory of drive C is %s\n",buf);
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Extraction notes
- heading `.getdcwd` read as `_getdcwd`
Stable link: /3.1/direct.h/_getdcwd/
· short form /3.1/_getdcwd/