gpt4 book ai didi

c - 声明主要原型(prototype)

转载 作者:太空狗 更新时间:2023-10-29 16:40:34 24 4
gpt4 key购买 nike

有什么原因导致我从未在 C 程序中看到 main 的原型(prototype)声明,即:

int main(int argc, char* argv[]);

int main(int argc, char* argv[])
{
return 0;
}

总是看起来不一致..

最佳答案

C 语言标准草案 n1256 :

5.1.2.2.1 Program startup

1 The function called at program startup is named main. The implementation declares noprototype for this function. It shall be defined with a return type of int and with noparameters:


int main(void) { /* ... */ }


or with two parameters (referred to here as argc and argv, though any names may beused, as they are local to the function in which they are declared):


int main(int argc, char *argv[]) { /* ... */ }


or equivalent; 9) or in some other implementation-defined manner.

强调我的。

关于c - 声明主要原型(prototype),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5020362/

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