How to effectively parse this command line in C++?
program -parameter1=value1 -parameter2=value2 -parameter3=value3
How to effectively drop a combination of the parameter and value
-parameter=value
I am trying to use this code but it does not work properly:
parameter[256], value[256],
while ( --argc > 0 )
{
if ( *argv[argc] == '-' )
{
for ( char * text = argv[argc]; ; )
{
switch ( * ( ++ text ) )
{
case '=' :
{
*value = *( text );
break;
}
default:
{
*parameter = *text;
}
}
}
//Testing parameters and values
}
}
Thanks for your comments and improvements.
value[256]cries for buffer overflow.