Hello All,
Im trying to get the working directory where my application resides. My actual code uses getcwd.
The result is the current working directory that my user is in the shell session.Code:#include <unistd.h> #include <limits.h> main() { char *cwd; char buf[PATH_MAX+1]; if((cwd = getcwd(buf, PATH_MAX+1)) == NULL) { perror("pwd"); exit(1); } puts(cwd); }
If I do this:
cd /tmp
/home/user/cwd
the return is /tmp and not /home/user
Is there a way to get the working directory where the app resides and not the cwd where the user is ?
Thanks,