I have written a simple application that reads a data file, parses the text and then does some processing on that data. The data file is opened in my main() function. Is it good
There are two aspects. One is the interest of deciding to stop the program at the place you want to use exit
, the other is the use of exit. Mat's answer covers the first.
For the second, exit
is usually a bad choice in C++. The reason is that it does some cleanup (functions registered with atexit
and that sometimes include destructors of some objects of static storage duration), but not all of them (destructors of objects on the stack) and in my experience you either want all of it or none.