#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.
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.
#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
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