It's defined by C standard as
0 for success and
1 for fail. This value returned to OS from main, exit or similar calls.
The reason why main use 0 for success is that it is used as the exit code of the application to the operating system, where 0 typically means success and 1 (or higher) means failure. (Of course, you should always use the predefined macros
Inside an application, however, it's more natural to use zero for failure and non-zero for success, as the return value can directly be used in an
But for greater portability, you can use macros
EXIT_FAILURE for conventional status value for success and failure, respectively. They are declared in file "stdlib.h".