目录

void exit(int status)

描述 (Description)

C库函数void exit(int status)立即终止调用进程。 属于该进程的任何打开文件描述符都将被关闭,进程的任何子进程都由进程1,init继承,并且进程父进程发送SIGCHLD信号。

声明 (Declaration)

以下是exit()函数的声明。

void exit(int status)

参数 (Parameters)

  • status - 这是返回到父进程的状态值。

返回值 (Return Value)

此函数不返回任何值。

例子 (Example)

以下示例显示了exit()函数的用法。

#include <stdio.h>
#include <stdlib.h>
int main () {
   printf("Start of the program....\n");
   printf("Exiting the program....\n");
   exit(0);
   printf("End of the program....\n");
   return(0);
}

让我们编译并运行上面的程序,它将产生以下结果 -

Start of the program....
Exiting the program....
↑回到顶部↑
WIKI教程 @2018