M
mlt
I have an application with the follwowing main function:
int main(int argc, char * argv[])
{
String p1, p2, c;
switch ( argc ){
case 1:{
std::cerr << "case1" << std::endl;
return 1;
}
case 2:{
p1 = argv[1];
std::cerr << "case2" << std::endl;
return 1;
}
case 3:{
p1 = argv[1];
p2 = argv[2];
std::cerr << "case3" << std::endl;
break;
}
case 4:
p1 = argv[1];
p2 = argv[2];
c = argv[3];
break;
}
I run it from cmd like:
app.exe 2 "c:\test\test.txt"
But it matches case 3. I also matches case 3 if I do:
app.exe 7 "c:\test\test.txt"
I thought that the first argument to app.exe would be stored in 'argc' which
is then switched upon. But that seems not to be the case, any ideas?
int main(int argc, char * argv[])
{
String p1, p2, c;
switch ( argc ){
case 1:{
std::cerr << "case1" << std::endl;
return 1;
}
case 2:{
p1 = argv[1];
std::cerr << "case2" << std::endl;
return 1;
}
case 3:{
p1 = argv[1];
p2 = argv[2];
std::cerr << "case3" << std::endl;
break;
}
case 4:
p1 = argv[1];
p2 = argv[2];
c = argv[3];
break;
}
I run it from cmd like:
app.exe 2 "c:\test\test.txt"
But it matches case 3. I also matches case 3 if I do:
app.exe 7 "c:\test\test.txt"
I thought that the first argument to app.exe would be stored in 'argc' which
is then switched upon. But that seems not to be the case, any ideas?