GETCWD(3V) — NEWS-OS Programmer’s Manual
NAME
getcwd − get path-name of current working directory
SYNOPSIS
char ∗getcwd(buf, size)
char ∗buf;
int size;
DESCRIPTION
getcwd returns a pointer to the current directory path-name. The value of size must be at least one greater than the length of the path-name to be returned.
If buf is not NULL, the pathname will be stored in the space pointed by buf.
If buf is a NULL pointer, getcwd will obtain size bytes of space using malloc(3). In this case, the pointer returned by getcwd may be used as the argument in a subsequent call to free(3).
EXAMPLE
char ∗cwd, ∗getcwd();
if ((cwd = getcwd((char ∗)NULL, 64)) == NULL) {
perror("gwtcwd");
exit(1);
}
printf("%s\n", cwd);
SEE ALSO
DIAGNOSTICS
Returns NULL with errno set if size is not large enough, or if an error ocurrs in a lower-level function.
NEWS-OSRelease 4.2.1R