title: C or C++ Return Status
body: <p>What are the best practices for writing C or C++ functions that return an int that represents a status code?</p>
  
  <p>Specifically, I want to know about the client usage but other tips are welcome.</p>
  
  <p>For example, can I write something like this:</p>
  
  <pre><code>int foo() {
    return 0;  // because everything was cool
  }
  </code></pre>
  
  <p>And then use it like this?</p>
  
  <pre><code>if (foo()) {
    // what to do if false, e.g. non-zero, e.g. not OK
  } else {
    // what to do if true, e.g. zero, e.g. OK
  }
  </code></pre>
  
  <p>This should work because best practices typically dictate that a status code of <code>0</code> means everything was OK and also <code>0</code> means <code>false</code> in a boolean statement.</p>
  
  <p>However, this wouldn't be good, right:</p>
  
  <pre><code>if (!foo()) {
    // what to do if true
  } else {
    // what to do if false
  }
  </code></pre>