搜尋

首頁  >  問答  >  主體

c++ - exit(EXIT_FAILURE)做了什麼?

exit(EXIT_TRUE),做了這些:

1. Objects associated with the current thread with thread storage duration are destroyed (C++11 only).

2. Objects with static storage duration are destroyed (C++) and functions registered with atexit are called.

3. All C streams (open with functions in <cstdio>) are closed (and flushed, if buffered), and all files created with tmpfile are removed.
Control is returned to the host environment.

那exit(EXIT_FAILURE)呢?

仅有的幸福仅有的幸福2810 天前1228

全部回覆(1)我來回復

  • 滿天的星座

    滿天的星座2017-05-31 10:40:51

    EXIT_SUCCESSEXIT_FAILURE是兩個常數。一般EXIT_SUCCESS=0EXIT_FAILURE=1

    exit()函數先處理完上面你列出的許多後事,最後將它的參數回傳給作業系統作為exit status。所以從exit函數本身執行來說並沒有什麼不同。不同的是作業系統對這個exit status的解釋。一般0表示程序壽終正寢,1表示死於非命。

    回覆
    0
  • 取消回覆