command-line argument problems
===

I am attempting to implement command-line options into my code. For some reason, my -a option works correctly, but my -c option does not work well, even though they are basically the same. I get the following message when I try to run my code with the -c option.

    terminate called after throwing an instance of 'std::logic_error'
    what():  basic_string::_S_construct NULL not valid
    Aborted

Below is my code.

    int c;
	std::string config = def+std::string("SamplesConfig.xml");
	std::string cal = def+std::string("calibration.bin");
	while ((c = getopt(argc, argv, "a:b:c"))>=0)
	{
		switch(c)
		{
			case 'a':
			{
				config = std::string(optarg);
				printf("%s", (char *)config.c_str());
				break;
			}
			case 'c':
			{
				cal = std::string(optarg);
				printf("%s", (char *)cal.c_str());
				break;
			}
			case 'b':
				config = std::string(optarg);
				cal = std::string(optarg);
				break;
			default:
			{
				break;
			}
		}
	}