#include <stdio.h>
#include <stdlib.h>

int main(void) {
    if (printf("Hello world!\n") < 0) {
        exit(EXIT_FAILURE);
    }
    return 0;
}

在输出时,使用 printf 函数,如果输出失败,函数会返回一个负数,此时程序应该退出并返回一个非零的状态码。使用 stdlib.h 头文件中的 EXIT_FAILURE 宏定义来表示退出状态。

用 C 语言写个程序输出 Hello world!注意输出失败时的退出状态

原文地址: https://www.cveoy.top/t/topic/Crd 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录