Can some explain me the diffrence between "return 0" and "return 1." or "return 2"? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can some explain me the diffrence between "return 0" and "return 1." or "return 2"?

9th Jul 2016, 12:30 PM
Vaasu Bhatnagar
Vaasu Bhatnagar - avatar
1 Answer
+ 1
Whatever you return from main typically gets fed back to whatever launched the program. A return value of zero indicates the program ran successfully, whereas nonzero indicates a failure of some kind. For stand-alone programs it doesn't really matter all that much, as this code is often ignored. But for launching programs inside batch scripts, where multiple programs need to run in succession... an error code could halt the entire script.
9th Jul 2016, 6:10 PM
imnoob
imnoob - avatar