+ 1
Is there any difference between exit(0) & exit(1) ?
I often used exit(0) to exit from program .what's exit(1) & it's use??
3 ответов
+ 4
You should return from main normally whenever possible instead of using exit().
The value returned by your program can be used when it was launched by another program. A return value of 0 means no error, and a non-zero value means anything you want, and you can use that return value in the main program to do stuff differently.
Needless to say, it's not often used.
+ 3
exit 0 is successfully exiting the program as intended exit 1 is exit failure or can be a program crashed. I believe in c++ this is return 0; and exit 0 is written in c. but it can be used with c++ if it's what you desire.
0
Thank you so much. @Zen @Name less