Should we use exit() in C?

前端 未结 7 1109
醉梦人生
醉梦人生 2020-12-02 16:44

There is question about using exit in C++. The answer discusses that it is not good idea mainly because of RAII, e.g., if exit is called somewhere

相关标签:
7条回答
  • 2020-12-02 17:14

    You don't have constructors and destructors but you could have resources (e.g. files, streams, sockets) and it is important to close them correctly. A buffer could not be written synchronously, so exiting from the program without correctly closing the resource first, could lead to corruption.

    0 讨论(0)
提交回复
热议问题