I want to parse the command line options having specific format for getting the values. The function is as follows
char* getCmdOption(char** begin,
char** end,
const std::string& option)
{
char** itr = std::find(begin, end, option);
if (itr != end && ++itr != end)
{
return *itr;
}
return (char*)"";
}
The arguments passed are getCmdOption(argv, argv+argc, "--optionName")
The code works fine for all the options and gives proper output but if I want to give values such as Application.exe --optionName surname="O Kief"
the code should return me surname="O Kief"
but instead it returns "surname=O Keif"
The format for input is Application.exe --optionName optionValue
and expected output is "optionValue"
What is possibly wrong with the logic ? And how can i handle the case I have mentioned ?