gpt4 book ai didi

c - 用返回类型定义的函数没有 return 语句?

转载 作者:行者123 更新时间:2023-11-30 21:23:03 29 4
gpt4 key购买 nike

#include <stdio.h>

int main(void)
{
printf("Hello, World\n");
}

在上面的代码中(最初显示为 picture ),main 函数的返回类型是 int 但我们没有在该函数中返回任何值。即使没有 return 语句,该函数也能工作。

这怎么可能?

最佳答案

截至C99 ,定义明确。

§ 5.1.2.2.3 程序终止

reaching the } that terminates the main function returns a value of 0.

关于c - 用返回类型定义的函数没有 return 语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48472733/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com