I put return 0 和 don't put on the program 有什么区别

Oss*_*Jr. 1 c return

#include <stdio.h>
int main()
    {
        for (int  i = 0; i < 10; i++)
        {
            printf("%d",i);
        }
        
    }
Run Code Online (Sandbox Code Playgroud)

我只是想知道为什么程序的结果无论return 0;是否放在代码上结果仍然是正确的。

Die*_*Epp 8

没有区别。

\n

根据 C 标准,您可以省略return 0;function main()(并且仅省略该 function),它仍然会表现得好像return 0;末尾有 a 一样。

\n

C标准中的准确写法:

\n
\n

[\xe2\x80\xa6]到达终止 main 函数的 } 返回值 0。

\n
\n

来自 n2346 \xc2\xa75.1.2.2.3 程序终止。

\n