man pages section 3: Basic Library Functions

Exit Print View

Updated: July 2014
 
 

getwd(3C)

Name

getwd - get current working directory pathname

Synopsis

#include <unistd.h>

char *getwd(char *path_name);

Description

The getwd() function determines an absolute pathname of the current working directory of the calling process, and copies that pathname into the array pointed to by the path_name argument.

If the length of the pathname of the current working directory is greater than (PATH_MAX + 1) including the null byte, getwd() fails and returns a null pointer.

Return Values

Upon successful completion, a pointer to the string containing the absolute pathname of the current working directory is returned. Otherwise, getwd() returns a null pointer and the contents of the array pointed to by path_name are undefined.

Errors

No errors are defined.

Usage

For portability to implementations conforming to versions of the X/Open Portability Guide prior to SUS, getcwd(3C) is preferred over this function.

Attributes

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Standard

See also

getcwd(3C), attributes(5), standards(5)