Without access to argv[0], how do I get the program name?
问题 I know the program name is passed as the first argument, and next simple example will print it to the standard output : #include <iostream> int main ( int argc, char *argv[] ) { std::cout<<argv[0]<<std::endl; } Is there a function to get the program name? EDIT I am starting the program from the shell, and the above code will always print the program name (I am using fedora 9, but I am sure it works in other distros). I have found that /proc/self/ directory might contain what I am looking for,