abc*_*cde 2 c++ command-line parsing
如何在C++中有效地解析这个命令行?
program -parameter1=value1 -parameter2=value2 -parameter3=value3
Run Code Online (Sandbox Code Playgroud)
如何有效地删除参数和值的组合
-parameter=value
Run Code Online (Sandbox Code Playgroud)
我试图使用此代码,但它无法正常工作:
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
}
}
Run Code Online (Sandbox Code Playgroud)
感谢您的意见和改进.
| 归档时间: |
|
| 查看次数: |
692 次 |
| 最近记录: |