exit() – C语言库函数
C库函数 void exit(int status) 立即终止调用进程。任何打开的文件描述符属于过程中被关闭,任何子进程继承和之父进程1,初始化,发送信号SIGCHLD。
声明
以下是exit() 函数的声明。
voidexit(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....