0
I did not understand the use of return 0; please help
2 Answers
+ 3
every program should output a return code after it's finished. This is used to see if the program terminated successfully or it encountered a problem and had to be terminated.
return 0 in main will output the code 0 which means your program terminated successfully, anything but 0 means that there was a problem. That's why main has int as a return type and you should end your program with return 0
+ 1
Entirely with @bogdan. Only addition: There are some predefined EXIT codes that are used in POSIX shells and should therefore be avoided.
All EXIT codes above 127: if the program was interrupted via a SIGNAL it should exit with 128+SIGNAL. but your shell will most likely do this automatically
127: Executable not found
126: Executable not executable
125(is used by `git bisect` but you can usually ignore that): Should be used to indicate a untestable revision if this a test script to test your repo.