title: What's an effective way to parse command line parameters in C++?
body: <p>Is there a really effective way of dealing with command line parameters in C++?</p>
  
  <p>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.</p>
  
  <pre>
  // Command line usage: sum num1 num2
  
  int main(int argc, char *argv[])
  {
  &nbsp;&nbsp;&nbsp;if (argc &lt; 3)
  &nbsp;&nbsp;&nbsp;{
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout &lt;&lt; "Usage: " &lt;&lt; argv[0] &lt;&lt; " num1 num2\n";
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit(1);
  &nbsp;&nbsp;&nbsp;}<br>
  &nbsp;&nbsp;&nbsp;int a = atoi(argv[1]);
  &nbsp;&nbsp;&nbsp;int b = atoi(argv[2]);
  &nbsp;&nbsp;&nbsp;int sum = a + b;<br>
  &nbsp;&nbsp;&nbsp;cout &lt;&lt; "Sum: " &lt;&lt; sum &lt;&lt; "\n";<br>
  &nbsp;&nbsp;&nbsp;return 0;
  }
  </pre>