Return 0 | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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
3 Respostas
+ 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