C Reference function exit()

The function exit() will terminate the process that calls the exit.

Usage of exit():

void exit ( int status );

On call the process will terminate normally. It will perform regular cleanup as normal for a normal ending process. (For example atexit functions are executed.)


A status value returned to the parent process.

Return value:

The argument status is returned to the host environment.
Normally you say 1 or higher if something went wrong and 0 if everything went ok. For example exit(o) or exit (1).

Source code example of exit():


	int main ()
		int * buffer;

		/*get a initial memory block*/
		if (buffer==NULL)
			printf("Error allocating memory!");
			exit (1);

		free (buffer);
		return 0;



There is currently one response to “C Reference function exit()”


  1. @vijaynitj on February 1st, 2013:

    thnk you so much for such beautiful effort…