When writing a C/C++ program, specifically with latest compilers, why do we need to return an integer from the main() method? Like int main() and we return "return 0" from it. So what is the exact reason behind this?
The return value of main() becomes the exit status of the process. Traditionally, an exit status of zero usually means “OK,” while any non-zero value indicates some kind of error. This is analogous with how many system calls likewise return zero or an error code.
Even more information at J. Leffler's epic answer to this, similar question: What should main() return in C and C++?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With