www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1993/03/11/03:28:51

To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: How to obtain full path name
From: alane AT wozzle DOT linet DOT org (J. Alan Eldridge)
Date: Wed, 10 Mar 93 22:05:00 EST
Organization: Disorganization

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019