.\" Copyright (c) 1991 The Regents of the University of California.
.\" %sccs.include.redist.man%
.\" @(#)getcwd.3 6.3 (Berkeley) %G%
getwd \- get working directory pathname
char *getcwd(char *buf, size_t size);
function copies the absolute pathname of the current working directory
into the memory referenced by
argument is the size, in bytes, of the array referenced by
is NULL, space is allocated as necessary to store the pathname.
is a compatibility routine which calls
argument and a size of MAXPATHLEN (as defined in the include
should be at least MAXPATHLEN bytes in length.
These routines have traditionally been used by programs to save the
name of a working directory for the purpose of returning to it.
A much faster and less error-prone method of accomplishing this is to
open the current directory (``.'') and use the
Upon successful completion, a pointer to the pathname is returned.
Otherwise a NULL pointer is returned and
is set to indicate the error.
copies the error message associated with
into the memory referenced by
Read or search permission was denied for a component of the pathname.
A component of the pathname no longer exists.
Insufficient memory is available.
argument is greater than zero but smaller than the length of the pathname
does not do sufficient error checking and is not able to return very
It is provided for compatibility.
chdir(2), fchdir(2), malloc(3), strerror(3)
conforms to IEEE Std 1003.1-1988 (``POSIX'').
The ability to specify a NULL pointer and have
allocate memory as necessary is an extension.