In my program I use chdir a number of times, and was wondering if there is a function that returns the directory in which the program is contained? I am looking for an alternative to:
1) create a global variable original_root to store the path in at the beginning of program
2) call getcwd(".") and store the returned value in variable original_root
3) chdir(some_other_path1)
4) chdir(some_other_path2)
.
.
.
x) chdir(some_other_pathn)
x+1) chdir(original_root)
Essentially, I'm wondering if there is some function that can be called at any time to give the path to the directory from which the program is being run, thus avoiding the need to save this directory in some variable. Thanks in advance!