get pathname of current working directory
char getcwd(char buf, size_t size);
returns a pointer to
the current directory pathname.
The value of
must be at least one greater than the length of the
pathname to be returned.
the pathname will be stored in the space pointed to by buf.
bytes of space using
In this case, the pointer returned by
may be used as the argument in a subsequent call to
is not large enough, or if an error occurs
in a lower-level function.
getcwd will fail if one or more of the following are true:
A parent directory cannot be read to get its name.
size is equal to 0.
size is less than 0 or
is greater than 0 and less than the length of the pathname plus 1.
Here is a program
that prints the current working directory.
if ((cwd = getcwd(NULL, 64)) == NULL)
This routine conforms to X/Open System Interfaces and Headers,
Issue 4, Version 2.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005