exit() - C語言庫函數

C庫函數  void exit(int status) 立即終止調用進程。任何打開的檔描述符屬於過程中被關閉,任何子進程繼承和之父進程1,初始化,發送信號SIGCHLD。

聲明

以下是exit() 函數的聲明。

void exit(int status)

參數

  • status -- 這是返回狀態值給父進程。

返回值

這個函數無返回值。

例子

下麵的例子演示了如何使用 exit() 函數。

#include <stdio.h>
#include <stdlib.h>

int main ()
{
   printf("Start of the program....
");

   printf("Exiting the program....
");
   exit(0);

   printf("End of the program....
");

   return(0);
}

讓我們編譯和運行上面的程式,這將產生以下結果:

Start of the program....
Exiting the program....

上一篇: atexit() - C語言庫函數 下一篇: getenv() - C語言庫函數