GETCWD(3C-POSIX) RISC/os Reference Manual GETCWD(3C-POSIX)
NAME
getcwd - get path-name of current working directory
SYNOPSIS
char *getcwd (buf, size)
char *buf;
sizet size;
DESCRIPTION
getcwd returns a pointer to the absolute pathname of the
current working directory. The value of size must be at
least two greater than the length of the path-name to be
returned.
If buf is a NULL pointer, 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
void exit(), perror();
.
.
.
if ((cwd = getcwd((char *)NULL, 64)) == NULL) {
perror("pwd");
exit(2);
}
printf("%s\n", cwd);
RETURN VALUES
Returns NULL with errno set if size is not large enough, or
if an error occurs in a lower-level function.
ERRORS
If any of the following conditions occur, getcwd returns
NULL and sets errno to the corresponding value:
[EINVAL] size is equal to zero.
[ERANGE] size is greater than zero, but less than
the length of the pathname plus 1.
[EACCES] Read or search permission was denied for
a component of the pathname.
[ENOMEM] buf is a NULL pointer, and malloc was
unable to allocate size bytes.
SEE ALSO
malloc(3C).
Printed 1/15/91 Page 1