Is there a really effective way of dealing with command line parameters in C++?
What I'm doing below feels completely amateurish, and I can't imagine this is how command line parameters are really handled (atoi, hard-coded argc checks) in professional software.
// Command line usage: sum num1 num2 int main(int argc, char *argv[]) { if (argc < 3) { cout << "Usage: " << argv[0] << " num1 num2\n"; exit(1); }
int a = atoi(argv[1]); int b = atoi(argv[2]); int sum = a + b;
cout << "Sum: " << sum << "\n";
return 0; }