Please post code within CODE tags, so that the code indentation is preserved. (Please re-edit your post to add formatted code).
As for popen(), it is meant to invoke a command. It would seem the command you want to invoke is the same as the name of the executable that is calling popen()? Is this what you really want?
Here's a working example of using popen():
FILE* fp = popen("/sbin/ifconfig eth0", "r");
while (fgets(buf, sizeof(buf), fp))
std::cout << buf << std::endl;
std::cerr << "Cannot execute /sbin/ifconfig." << std::endl;
P.S. You should avoid developing s/w under the root account.