0

Return 0

The further I go along in the C++ lessons the less that return 0 is used at the end of the code. If my understanding is correct the program will return a value upon completion regardless of successful completion. Is the return 0 supposed to be implied? I would think that it would be good programming practice. Thank you for any insight.

5th Jul 2020, 12:28 PM
GeoK68
GeoK68 - avatar
4 odpowiedzi
+ 1
Maybe the function main() is starting as void main() which do not need anything to return when the program ends because of void datatype.
5th Jul 2020, 12:44 PM
Lakshay Mittal
Lakshay Mittal - avatar
0
return 0 is typically used to indicate the successful completion of the program. C++ specifically allows you to fall off the main() function without explicitly returning anything. The compiler automagically includes a return 0;  there.
5th Jul 2020, 12:48 PM
123