Correct usage of exit() in c++?

后端 未结 6 1212
再見小時候
再見小時候 2021-02-12 10:31

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

6条回答
  •  臣服心动
    2021-02-12 10:58

    Exit is acceptable, although I believe it is important to note the differences in memory of using exit vs. a return statement in that exit will not destroy variables in memory. If there is some error, then exit is justified. Otherwise, I would stick to the return statement.

提交回复
热议问题