C/C++函數返回1和返回0究竟哪個好?
C/C++函數返回1和返回0究竟哪個好?
資料來源: https://mp.weixin.qq.com/s/k665sVh1vaXvEXhWD1iAYQ
https://docs.microsoft.com/zh-tw/cpp/c-runtime-library/exit-success-exit-failure?view=msvc-160
線上編譯器:
https://www.tutorialspoint.com/compile_cpp_online.php
https://www.tutorialspoint.com/compile_c_online.php
<stdlib.h>標準頭文件裡預先定義好的EXIT_SUCCESS 和EXIT_FAILURE 宏。
常數 定義的值
EXIT_SUCCESS 0
EXIT_FAILURE 1
CODE:
#include <stdio.h> #include <stdlib.h> int main() { printf("Hello, World!\n"); return EXIT_SUCCESS;//0; }
#include <iostream> #include <cstdlib> using namespace std; int main() { cout << "Hello World" << endl; return EXIT_SUCCESS;//0; }