Hi,
I am not sure how to use int argc, char* argv[]. Anyone could tell me when should I use it?
Also, I cannot compile the following code. The error shows initialization of 'i' is skipped by 'default' label. What does it mean?
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
switch(argc-1)
{
case 2:
case 3:
case 4:
for(int i = 1; i < argc; i++)
cout << "Argument " << i << " is " << argv[i] << endl;
break;
default:
cout << "You entered the incorrect number of arguments. " << endl
<< "Please enter 2, 3 or 4 arguments only. " << endl;
}
return 0;
}
Thanks in advance.
gogo



LinkBack URL
About LinkBacks


