+ 2

Why return 0 is used

13th Aug 2017, 6:17 AM
Manas
3 Respuestas
+ 9
In C++ programs the main function is of type int and therefore it should return an integer value. Thereturn value of the main function is considered the "Exit Status" of the application. On most operating systems returning 0 is a success status like saying "The program worked fine". It is actually up to you to determine which return value you want to signal that your program has run successfully. In other situations where your program just crashes due to faulty pointers, the value will not be 0.
13th Aug 2017, 6:30 AM
Dev
Dev - avatar
+ 4
The return value of main function is passed to the caller of the program in the system shell. There is a convention to interpret 0 return value as successful termination of the program, and any nonzero value as termination with an error. This may be used in the OS shell scripts to know if the task was completed successfully.
13th Aug 2017, 6:29 AM
deFault
+ 1
thanks a lot
13th Aug 2017, 6:30 AM
Manas