c++ - Why is explicitly returning 0 from main() considered good practice? -
possible duplicate:
return statement vs exit() in main()
i've read first chapter of accelerated c++ (seems awesome book), , @ end author says
however, explicitly including return main practice.`
why considered practice? in c99, omitted return 0
, using exit()
signal abnormal program termination, , never missed explicit return.
in c99 , in c++ if execution of program reaches closing brace of main()
function implicit return 0;
executed. wasn't case in c90 - reaching end of main()
without explicit return
result in indeterminate value being returned (strictly speaking, behavior undefined).
i can guess authors of "accelerated c++" feel explicit return practice because makes intent explicit. other reason can think of makes code compatible c90, find difficult believe that hold weight reason.
Comments
Post a Comment