C++

Asked • 04/24/19

return statement vs exit() in main()?

Should I use `exit()` or just `return` statements in `main()`? Personally I favor the `return` statements because I feel it's like reading any other function and the flow control when I'm reading the code is smooth (in my opinion). And even if I want to refactor the `main()` function, having `return` seems like a better choice than `exit()`.Does `exit()` do anything special that `return` doesn't?

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.