Easy Tutorial
❮ C Function Getenv C Exercise Example70 ❯

C Library Function - exit()

C Standard Library - <stdlib.h>

Description

The 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, initialized, and a SIGCHLD signal is sent to the parent process.

Declaration

Following is the declaration for the exit() function.

void exit(int status)

Parameters

Return Value

This function does not return any value.

Example

The following example demonstrates the use of the exit() function.

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

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:

Beginning of the program....
Exiting the program....

C Standard Library - <stdlib.h>

❮ C Function Getenv C Exercise Example70 ❯