+ 1

return 0; inside main.

I understand that return 0; in main function indicates that the program is successful, but some compilers do not care. I tried to run it without return 0; and it worked, why ?

31st Dec 2016, 2:24 AM
Kourosh Azizi
Kourosh Azizi - avatar
3 Réponses
+ 2
Hi, In C++ adding return 0; is optional as the compiler automatically adds a return 0; if you don't explicitly return a value. The return value is the exit code of a program the shell (or any other application) can read and use it. Hope this was helpful :-)
31st Dec 2016, 3:07 AM
Yukeshkumar N
Yukeshkumar N - avatar
0
Thanks
31st Dec 2016, 3:42 AM
Kourosh Azizi
Kourosh Azizi - avatar
0
@Kourosh Azizi .. Welcome.. 😊
31st Dec 2016, 2:08 PM
Yukeshkumar N
Yukeshkumar N - avatar