A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://en.cppreference.com/w/c/numeric/math/../../io/../program/EXIT_status.html below:

EXIT_SUCCESS, EXIT_FAILURE - cppreference.com

#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 exit function (and, therefore, as the values to return from the main function), and indicate program execution status.

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 exit), although it is not required that EXIT_SUCCESS equals zero.

[edit] Example
#include <stdio.h>
#include <stdlib.h>
 
int main(void)
{
    FILE* fp = fopen("data.txt", "r");
    if (fp == NULL)
    {
       fprintf(stderr, "fopen() failed in file %s at line #%d", __FILE__, __LINE__);
       exit(EXIT_FAILURE);
    }
 
    /* Normal processing continues here. */
    fclose(fp);
    printf("Normal Return\n");
 
    return EXIT_SUCCESS;
}

Output:

fopen() failed in file main.cpp at line #9
[edit] References
[edit] See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4