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, but I couldn't find what exactly in that directory.