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

Popular posts from this blog

c++ - How to modify context menu of internet explorer using IDocHostUIHandler::ShowContextMenu? -

android - Spacing between the stars of a rating bar? -

c# - Getting "Internal .Net Framework Data Provider error 30" error when column has NULL value -