title: "Proper" way to exit from a C/C++ program on erroneous input/behavior
body: <p>Quick question.. is there a "proper" way to terminate from a C/C++ program on invalid input? Thus far, my career in C/C++ has involved doing something like this:</p>
  
  <pre><code>// C
  #include &lt;stdio.h&gt;
  int main(int argc, char **argv)
  {
      if (argc != 3) {
          fprintf(stderr, "Error: Usage: %s [some param] [some param]\n", argv[0]);
          return 1;
      }
  
      /* rest of program */
  
      return 0;
  }
  </code></pre>
  
  <p>In C++, it could be <code>cerr</code> instead of <code>fprintf(srderr...)</code> and <code>iostream</code> instead or <code>stdio.h</code>.</p>
  
  <p>Is this an OK/acceptable way, or is there a standard I'm not aware of?</p>
  
  <p>Thanks!</p>