4 ms·
One of my biggest bugbears on C / C++ programming is return 0; I wish people would #include <stdlib.h> /<cstdlib> and use EXIT_SUCCESS / EXIT_FAILURE just to ma
by jpm48 6y ago
One of my biggest bugbears on C / C++ programming is return 0; I wish people would #include <stdlib.h> /<cstdlib> and use EXIT_SUCCESS / EXIT_FAILURE just to make the code more obvious for the beginner on what the intent is. :-) To quote the "zen of python" "Explicit is better than implicit" we know what "SUCCESS" or "FAILURE" is! And we can use enums for other exit values.
- mav3rick 6y agoThere should only be one way to succeed. Returning 0 for success makes complete sense. You can add layers of macros or enums to sugar coat this but retuning 0 for the success case makes complete sense
- saagarjha 6y agoReturning either EXIT_SUCCESS or 0 is a valid way to terminate the program with an implementation-defined exit code appropriate for your platform.