Main Function

The main function should always return a value which determines whether your program has terminated successfully. There are conventions for what sorts of status values certain programs should return. The most common convention is simply 0 for success and 1 for failure.

Good

int main() {
  // perform computation

  if (is_error) {
    // unsuccessful program completion
    return 1;
  }

  // program completed successfully
  return 0;
}