C++/C 写void main()都是不规范的

C/C++ 中从来没有定义过void main( ) 。C++ 之父Bjarne Stroustrup 在他的主页上的 technical FAQ 中明确地写着:
The definition
void main() { /* ... */ }
is not and never has been C++, nor has it even been C. See the ISO C++ standard 3.6.1[2] or the ISO C standard 5.1.2.2.1. A conforming implementation accepts
int main() { /* ... */ }
and
int main(int argc, char* argv[]) { /* ... */ }

如图:


image.png

链接如下:
https://www.stroustrup.com/bs_faq2.html

最好在main函数的最后加上return 语句,这是一个好习惯。

你可能感兴趣的:(C++/C 写void main()都是不规范的)