为什么 main() 不需要返回类型(比如 int),即使它返回一个整数? [英] Why main() does not need a return type(say int), even when it return an intiger?
本文介绍了为什么 main() 不需要返回类型(比如 int),即使它返回一个整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include<stdio.h>
main()
{
//
//
return 0;
}
我的意思是,即使我没有指定它的返回类型,上面的代码也没有显示任何错误.(只是'main'而不是'int main').
I meant, the above code does not shows any error even though I didn't specify the return type of it. (simply 'main' instead of 'int main').
推荐答案
这是旧式语法(C89 之前的),其中函数的默认返回类型为 int
.
This is old-style syntax (pre-C89) where the default return type of a function was int
.
AFAIK 它现在已被弃用,因此您应该始终提供返回类型.
AFAIK it has been deprecated by now, so you should always provide a return type.
这篇关于为什么 main() 不需要返回类型(比如 int),即使它返回一个整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文