how to get absolute path of current executing C/C++ prog?
i have a binary executeable
i thought about argv
but it only prints what is entered in the bash
so if you use
getcwd(); would only result /root in the above example *afaik*
the filename itself should be easy
i can use argv for this
but how do i get the PATH?
In linux or anywhere with a similar /proc setup, you can readlink() on /proc/self/exe . Be sure to read the man page for readlink(2) because it's not intuitive.
man 2 readlink
since there's a shell command with the same name as the system call
|All times are GMT -5. The time now is 03:24 PM.|