?
This document uses PHP Chinese website manual Release
在頭文件<stdlib.h>中定義 | ||
---|---|---|
#define EXIT_SUCCESS / *實(shí)現(xiàn)定義* / | ||
#define EXIT_FAILURE / *實(shí)現(xiàn)定義* / |
EXIT_SUCCESS
和EXIT_FAILURE
宏擴(kuò)展成可以被用作參數(shù)的積分表達(dá)式exit
函數(shù)(和,因此,作為這些值從主函數(shù)返回),并指示程序執(zhí)行狀態(tài)。
常量 | 說(shuō)明 |
---|---|
EXIT_SUCCESS | 成功執(zhí)行程序 |
EXIT_FAILURE | 程序執(zhí)行失敗 |
EXIT_SUCCESS和值零都表示成功的程序執(zhí)行狀態(tài)(參見(jiàn)退出),但不要求EXIT_SUCCESS等于零。
#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;}
輸出:
fopen() failed in file main.cpp at line # 9
C11標(biāo)準(zhǔn)(ISO / IEC 9899:2011):
7.22 / 3通用工具<stdlib.h>(p:340)
C99標(biāo)準(zhǔn)(ISO / IEC 9899:1999):
7.20 / 3通用工具<stdlib.h>(p:306)
C89 / C90標(biāo)準(zhǔn)(ISO / IEC 9899:1990):
4.10常用工具<stdlib.h>
| EXIT_SUCCESS,EXIT_FAILURE的C ++文檔 |