How do I get the directory that a program is running from?

Is there a platform-agnostic and filesystem-agnostic method to obtain the full path of the directory from where a program is running using C/C++? Not to be confused with the current working directory. (Please don’t suggest libraries unless they’re standard ones like clib or STL.)

(If there’s no platform/filesystem-agnostic method, suggestions that work in Windows and Linux for specific filesystems are welcome too.)

25 Answers
25

Leave a Comment