GETCWD(3P)GETCWD(3P)NAMEgetcwd - (POSIX only) get current working directory pathname
SYNOPSIS
char *getcwd(char *buf, size_t size);
DESCRIPTION
Getcwd is a POSIX function. BSD provides this functionality with the
getwd(3) function.
The getcwd function copies the absolute pathname of the current working
directory to the array pointed to by buf and returns a pointer to the
result. The size argument is the size in bytes of the array.
If buf is NULL, then getcwd allocates an array of char, copies the
pathname and returns a pointer to the array.
RETURN VALUE
Upon successful completion, getcwd returns the bufP argument.
Otherwise, a NULL pointer is returned and errno is set to indicate the
error.
ERRORS
If any of the following conditions occurs, the getcwd function returns
a NULL pointer and sets errno to the corresponding value:
[EAGAIN] The buf argument is NULL and getcwd fails to allocate an
array for the pathname.
[EINVAL] The size argument is zero.
[ERANGE] The size argument is greater than zero but smaller than
the length of the absolute pathname of the current
directory plus 1.
SEE ALSOchdir(2), getwd(3)
August 1, 1992 GETCWD(3P)