Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
getcwd, _getdcwd
◄Summary► ◄Example► ◄Up► ◄Contents► ◄Index► ◄Back►
────────────────────────────────────────────────────────────────────────────
The getcwd function gets the full path name of the current working
directory and stores it at <buffer>. The _getdcwd function gets
the full path name plus the disk drive specification.
For _getdcwd, the <drive> argument specifies the drive (0 =
default drive, 1=A, 2=B, etc.).
The integer argument <maxlen> specifies the maximum length for the
path name. An error occurs if the length of the path name
(including the terminating null character) exceeds <maxlen>. The
constant _MAX_PATH, defined in STDLIB.H, specifies the maximum
possible path length.
The <buffer> argument can be NULL; a buffer of at least size
<maxlen> (more only if necessary) will automatically be allocated
using malloc to store the path name. This buffer can later be
freed by calling free and passing it the return value of the
function (a pointer to the allocated buffer).
Return Value
Both the getcwd and _getdcwd functions return the path. A NULL
return value indicates an error, and errno is set to either ENOMEM
or ERANGE.
-♦-