I am not a professional programmer, so this is not an exact answer.
What you need to do is grab the PWD environment variable (current working directory)
I'm not sure which library it is in, but this is the standard linux header.
I will look around and see if I can find him.
edit:
I thought getenv () would help if you also need to run system commands and need various bin paths located in PATH
source
share