C library function - exit()
Description
C Library Function void exit(int status) Immediately terminates the calling process. Any open file descriptors belonging to the process are closed, the process's children are inherited by process 1 and initialized, and a SIGCHLD signal is sent to the parent process.
Declaration
The following is the declaration of the exit() function.
void exit(int status)
Parameters
- status -- The status value returned to the parent process.
Return Value
The function does not return a value.
Example
The following example demonstrates the use of the exit() function.
Example
#include
#include
int
main
(
)
{
printf
(
"Beginning of the program....\n"
)
;
printf
(
"Exiting the program....\n"
)
;
exit
(
0
)
;
printf
(
"End of the program....\n"
)
;
return
(
0
)
;
}
Let's compile and run the above program, which will produce the following result:
程序的开头....
退出程序....
C Standard Library -