I have code that is crashing:
if(argc<2)
{
printf("Too few arguments\n");
}
else if(argc>=2)
{
namespace po = boost::program_options;
po::options_description desc("Options");
desc.add_options()
("c")
("d")
("filename", po::value<string>());
po::variables_map vm;
po::store(po::parse_command_line(argc,argv,desc),vm);
po::notify(vm);
if(vm.count("c"))
{
// option c
}
else if(vm.count("d"))
{
// option d
}
}
Debug Error: This application has requested the Runtime to terminate it in an usual way...
I want my program to have options -c and -d and optional filename after them. How to add_options into options_description and next how to check if I have option -c, -d and if I have filename as command line parameter?
I've read tutorial for boost/program_options from boost site, but I can't figure how to do it.