getcwd - get name of current working directory
Standard C Library (libc, -lc)
#include <unistd.h>
char *
getcwd(char *buf, size_t buflen);
The name of the current directory is computed and stored in buf, an area of size buflen. The resulting string is 0-terminated.
This call is a wrapper (for Unix compatibility) around the system call __getcwd.
Note, however, that the BSD extension whereby space is allocated with malloc if buf is NULL is not supported.
On success, getcwd returns buf. On error, NULL is returned, and errno is set according to the error encountered.
The following error codes should be returned under the conditions given. Other error codes may be returned for other errors not mentioned here.
ENOENT | A component of the pathname no longer exists. | ||
EIO | A hard I/O error occurred. | ||
EFAULT | buf points to an invalid address. |