Integer type (typically 4 bytes, -2,147,483,648 to 2,147,483,647)
1st Parameter
The exit status code returned to the operating system; 0 typically indicates successful execution, while non-zero values indicate errors
Read more about parameters of exit in parameters section
The exitfunction in C language Terminates the program and returns control to the host environment.
The exit function terminates the calling process immediately. It first calls all functions registered with atexit() in reverse order of their registration, then flushes all open output streams, closes all open streams, and finally returns control to the host environment. The status value is typically used to return an exit status to the parent process or operating system. By convention, a status of 0 indicates successful termination, while non-zero values indicate various error conditions.
The exitfunction takes 1
parameter:
•
int `status`: The exit status code returned to the operating system; 0 typically indicates successful execution, while non-zero values indicate errors
Terminates the program immediately, performing cleanup by calling registered functions with `atexit` and flushing I/O buffers before returning the specified status to the operating system.
The exit function return value :
This function does not return to the calling process
Output
This example demonstrates the basic usage of the `exit` function. If an error condition is met, the program exits with a status code of 1, indicating an error occurred.