totn C Functions

C Language: exit function
(Exit from Program)

In the C Programming Language, the exit function calls all functions registered with atexit and terminates the program. File buffers are flushed, streams are closed, and temporary files are deleted.

Syntax

The syntax for the exit function in the C Language is:

void exit(int status);

Parameters or Arguments

status

Indicates whether the program terminated normally. It can be one of the following:

ValueDescription
EXIT_SUCCESSSuccessful termination
0Successful termination
EXIT_FAILUREUnsuccessful termination

Returns

The exit function does not return anything.

Required Header

In the C Language, the required header for the exit function is:

#include <stdlib.h>

Applies To

In the C Language, the exit function can be used in the following versions:

  • ANSI/ISO 9899-1990

Similar Functions

Other C functions that are similar to the exit function:

See Also

Other C functions that are noteworthy when dealing with the exit function: