getwd(3C)


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, then getwd fails and returns a NULL pointer. (See limits(4) for a description of PATH_MAX.)

Return value

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.

Compatibility

For portability to earlier implementations of the UNIX® system, getcwd(3C) is preferred over this function.

References

getcwd(3C)

Standards conformance

This routine conforms to X/Open System Interfaces and Headers, Issue 4, Version 2.
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004