getenv("PWD");
But that only tells the value of such environment variable at the time
the program was started.
I need to know (for debugging purposes) the current working directory,
dynamically.
TIA,
-Ramon
Bonus question:
Are the commands 'pushd' and 'popd' implemented programmatically?
That can lie if the invoker of your program is malicious.
The invoker of your program might not be a shell, and it might
not know to update $PWD or even provide it.
>But that only tells the value of such environment variable at the time
>the program was started.
Look at getcwd() (POSIX). This can fail due to permissions problems
(having x but not r permission on directories, for example.)
> Look at getcwd() (POSIX).
My program works great now, thanks Gordon!
-Ramon
I guess a good way to achieve the above is through a combination of
`getcwd()' and a std::vector which behaves like a stack. That should
be simple enough, at least for those of the C++ persuasion.
Thx,
-Ramon