0

I want to extract the name of the current binary and use it inside my program. Can I do this somehow?

#include <iostream>
int main(int argc, char** argv)
{
  std::cout << arv[0]; // print name of program
  return 0;
}

Basically, I want a portable version of the above? I am happy to use any Boost or Standard Library tools.

quant
  • 21,507
  • 32
  • 115
  • 211
  • there isn't one (although I don't know of a platform that doesn't usually work as you described). And this is a dupe. Lemme find it ( – sehe May 19 '15 at 00:04
  • As it goes with the questions that you figure must have been asked by others, the linked answer was from 2009 and has 217 upvotes. Wasn't hard to find :/ – sehe May 19 '15 at 00:07
  • @sehe that's disappointing. I'm surprised boost doesn't provide something. I think I didn't find the existing question because I didn't know what this was called... – quant May 19 '15 at 00:09
  • Something like "Application Framework" or something seems to be in the making with Boost [https://github.com/retf/Boost.Application]. PoCo already has it. You could look at those. – sehe May 19 '15 at 00:10

0 Answers0