getcwd() - get working directory pathname
#include <unistd.h>
char * getcwd (char *buf, size_t size)
The getcwd(2) function copies the absolute pathname of the current working directory into the memory referenced by buf and returns a pointer to buf. The size argument is the size, in bytes, of the array referenced by buf.
This routine has traditionally been used by programs to save the name of a working directory for the purpose of returning to it.
Upon successful completion, a pointer to the pathname is returned. Otherwise a NULL pointer is returned and the global variable errno is set to indicate the error.
If an error occurs, the contents of buf are not changed.
The getcwd(2) function will fail if:
chdir(2)