EXIT_SUCCESS, EXIT_FAILURE
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Utilities library
Type support (basic types, RTTI)
Library feature-test macros (C++20)
(C++11)
(C++20)
(C++26)
(C++20)
Coroutine support (C++20)
Contract support (C++26)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)(C++20)
(C++20)(C++20)(C++20)
General utilities
Relational operators (deprecated in C++20)
(C++20)(C++20)(C++20)
(C++20)(C++20)(C++20)
(C++20)
Swap and type operations
Common vocabulary types
Program support utilities
(C++23)
Defined in header
<cstdlib>
#define EXIT_SUCCESS /*implementation defined*/
#define EXIT_FAILURE /*implementation defined*/
The EXIT_SUCCESS
and EXIT_FAILURE
macros expand into integral constant expressions that can be used as arguments to the std::exit function (and, therefore, as the values to return from the main function), and indicate program execution status.
A freestanding implementation is required to provide EXIT_SUCCESS
and EXIT_FAILURE
.
Constant
Description
EXIT_SUCCESS
successful execution of a program
EXIT_FAILURE
unsuccessful execution of a program
[edit] Notes
Both EXIT_SUCCESS
and the value zero indicate successful program execution status (see std::exit ), although it is not required that EXIT_SUCCESS
equals zero.
Although EXIT_SUCCESS
and EXIT_FAILURE
are required to be freestanding since C++23, they are not required to be available in a freestanding C implementation.
[edit] Example
Run this code
Possible output:
The quick brown fox jumps over the lazy cat
[edit] See also
C documentation for EXIT_SUCCESS, EXIT_FAILURE