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

后端 未结 9 1657
佛祖请我去吃肉
佛祖请我去吃肉 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:48

    I often do it because I often compile code for straight C, so I either type it in out of habit or because the snippet I created main() from has the explicit return. There's no reason to remove it, so it usually stays.

    Then again, there are times when I won't bother typing it in (maybe I realized I didn't need it) or I may have used a different snippet.

提交回复
热议问题