What the reasons for/against returning 0 from main in ISO C++?

后端 未结 9 1659
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-20 19:12

I know that the C++ standard says that return 0 is inserted at the end of main() if no return statement is given; however, I often see recently-wri

9条回答
  •  醉酒成梦
    2021-01-20 19:40

    • Makes it clear to other programmers that you didn't just forget to put the return statement there.

    • Some compilers may issue a warning if you don't return anything.

    • Shows explicitly what the function returns.

    • Many programmers don't know about this rule.

提交回复
热议问题