Getting the cwd from within a C program

D. A. Dixon dixon at ihuxa.UUCP
Thu Oct 20 03:37:02 AEST 1983


If your system has the getcwd(3) library routine, then that will give
you the current working directory. If your system does not have
getcwd(3) OR you do not want to use it (because it uses popen() and 'pwd'
as noted by Guy Harris), then you can use the undocumented library routine
curdir() in libPW.a. This routine takes as an argument the address of an
array in which it can place the current directory. Since the routine is
undocumented you cannot assume it will be around in future releases of UN*X.
NOTE: Don't forget to compile with -lPW.

D A Dixon     ihuxa!dixon      BTL - IH



More information about the Comp.unix mailing list