getcwd

Returns a pointer to the file specification for the current working directory.

Format

#include  <unistd.h>

char *getcwd  (char *buffer, size_t size); (ISO POSIX-1)

char *getcwd  (char *buffer, unsigned int
              size, . . . ); (DEC C Extension)
Function Variants This function also has variants named _getcwd32 and _getcwd64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.8 for more information on using pointer-size-specific functions.

Arguments

buffer
Pointer to a character string large enough to hold the directory specification.

If buffer is a NULL pointer, getcwd obtains size bytes of space using malloc. In this case, you can use the pointer returned by getcwd as the argument in a subsequent call to free.

size
The length of the directory specification to be returned.
. . .
An optional argument that can be either 1 or 0. If you specify 1, the getcwd function returns the directory specification in OpenVMS format. If you specify 0, getcwd returns the directory specification (path name) in UNIX style format. If you do not specify this argument, getcwd returns the file name according to your current command-language interpreter. For more information about UNIX style directory specifications, see Section 1.4.3.

Return Values
A pointer to the file specification. 
NULL  Indicates an error. 


Previous Page | Next Page | Table of Contents | Index