Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost Options - Get application name

Is there a simple way to get the application name using Boost (maybe with boost::program_options?)

The thing will be like this:

Having argv[0] = "c:\foo\bar\appname.exe"

I want to have var1 = "appname"

like image 445
Santi Agüero Avatar asked Mar 02 '12 15:03

Santi Agüero


1 Answers

You can use boost::filesystem to extract the name from the path. that would look something like this:

#include <boost/filesystem.hpp>

boost::filesystem::path p = argv[0];
std::string var1 = p.stem().string();
like image 198
Tobias Schlegel Avatar answered Oct 15 '22 04:10

Tobias Schlegel