c语言exit函数(C语言库函数之exit()详解)

原函数

void exit(int status)

函数说明:void exit(int status) 立即终止调用进程。任何打开的文件描述符属于过程中被关闭,任何子进程继承和之父进程1,初始化,发送信号SIGCHLD。

参数:

  • status -- 是返回状态值给父进程。

返回值:

函数无返回值。

如何使用 exit() 函数:

#include <stdio.h>

#include <stdlib.h>

int main () {

printf("Line 1 - Start of the program.... n");

printf("Line 2 - Exiting the program.... n");

exit(0);

printf("Line 3 - End of the program.... n");

return 0;

}

编译和运行上面的程序,产生如下结果:

Line 1 - Start of the program....

exit函数

Line 2 - Exiting the program....

您可以还会对下面的文章感兴趣

使用微信扫描二维码后

点击右上角发送给好友