Returns the pathname of the current working directory.
#include <unistd.h> char *getcwd ( char *path, size_t len);
(OUT) Specifies the buffer in which to place the name of the current working directory. If passed as NULL, getcwd allocates a buffer the size of len and returns a pointer to that buffer. You must free the allocated buffer.
(IN) Specifies the length of the buffer (including space for the null-terminating character). If len is not large enough to hold the pathname, getcwd truncates the path. The truncated string placed in the buffer is not null terminated. If path is NULL, len must be set to at least PATH_MAX.
If successful, returns the address of the string containing the name of the current working directory. Otherwise, returns a NULL pointer and sets errno to one of the following:
The getcwd function returns the absolute pathname of the current working directory in the array pointed to by path.
The type of string returned, whether ASCII or UTF-8, depends upon your application's link flags.
On NetWare, the current working directory does not include the volume name.
If the current working directory is the root of a volume, getcwd returns "\".
If the current working directory is a subdirectory of the volume, for example sys:\public, getcwd returns "\public".
If you have set the current working directory for the current thread by calling setcwd2 or chdir2, the current working directory of the thread is returned. Otherwise, the current working directory of the VM is returned.