getcwd(3C) — AT&T SYSTEM V
NAME
getcwd − get path-name of current working directory
SYNOPSIS
char ∗getcwd (buf, size)
char ∗buf;
size_t size;
DESCRIPTION
The getcwd function copies an absolute pathname of the current working directory to the character array pointed to by the argument buf and returns a pointer to the result. The size argument is the size in bytes of the character array pointed to by the buf argument. If the buf argument is NULL, getcwd will obtain size bytes of space using malloc(3C). In this case, the pointer returned by getcwd may be used as the argument in a subsequent call to free.
EXAMPLE
char ∗cwd, ∗getcwd();
.
.
.
if ((cwd = getcwd((char ∗)NULL, 64)) == NULL) {
perror("getcwd");
exit(2);
}
printf("%s \n", cwd);
ERRORS
If any of the following conditions occur, the getcwd() function returns a value of NULL and sets the variable errno to indicate the error.
[EINVAL] The size argument is less than or equal to zero.
[ERANGE] The size argument is greater than zero, but is smaller than the length of the pathname plus 1.
[EACCES] Read or search permission was denied for a component of the pathname.
SEE ALSO
CX/UX Programmer’s Reference Manual