Mail Archives: djgpp/1993/03/11/03:28:51
Eric Backus <src4src!mcdhup!rutgers!lsid.hp.com!ericb> writes:
> I believe that the POSIX answer is:
>
> #include <unistd.h>
>
> char *getcwd(char *buf, size_t size);
>
> You pass it a buffer <buf> of size <size> bytes, and getcwd() fills in
> the buffer with the current working directory, and then returns <buf>.
> If something fails (like <size> is too small) the function returns
> NULL and sets errno. I believe that PATH_MAX bytes should always be
> big enough to hold the path. Or maybe you need PATH_MAX+1 for the
> null. I can't remember.
Also, if passed a NULL pointer it allocates space on the heap, which
the caller is responsible for freeing.
alane AT wozzle DOT linet DOT org (J. Alan Eldridge)
Fido: The University of Woolloomooloo 1:272/38.473
- Raw text -