01.01.2013 Views

AT&T UNIX™PC Unix System V Users Manual - tenox

AT&T UNIX™PC Unix System V Users Manual - tenox

AT&T UNIX™PC Unix System V Users Manual - tenox

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

GETCWD ( 3C } GETCWD ( 3C )<br />

NAME<br />

getcwd - get path-name of current working directory<br />

SYNOPSIS<br />

char *getcwd (buf, size)<br />

char *huf;<br />

int size;<br />

DESCRIPTION<br />

Getcwd returns a pointer to the current directory path-name.<br />

The value of size must be at least two greater than the length of<br />

the path-name to be returned.<br />

If buf is a NULL pointer, getcwd will obtain size bytes of space<br />

using malloc(3C). In this case, the pointer returned by getcwd<br />

may be used as the argument in a subsequent call to free.<br />

The function is implemented by using popen(3S) to pipe the output<br />

of the pwd(l) command into the specified string space.<br />

EXAMPLE<br />

char *cwd, *getcwd();<br />

if ((cwd = getcwd((char *)NULL, 64)) == NULL) {<br />

perror(''pwd");<br />

exit( I);<br />

}<br />

printf("%s\n", cwd);<br />

SEE ALSO<br />

pwd(l), malloc(3C), popen(3S).<br />

DIAGNOSTICS<br />

Returns NULL with errno set if size is not large enough, or if an<br />

error occurs in a lower-level function.<br />

- 1 -

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!