可能重复的区别:
difference between main(void) and main() in c在C:主()和int main()的
我知道这是超级基本和其他一些线程已经谈到了类似的问题。但是我有一本书(C的绝对新手指南),所有的代码都写在函数main()中。 int总是被忽略。这怎么可能运行?这可能是一个老版本的stdio.h吗?
下面是示例代码:
#include <stdio.h>
main() // not int main()
{
printf("This is it\n");
return 0;
}
主要区别在于时间。在1984年,可以写'main()'。在2012年,它并不好,但许多编译器接受它的向后兼容性。许多作者认为它仍然是80年代中期。 –
查看http://stackoverflow.com/questions/4260048/c-function-defined-as-int-but-having-no-return-statement-in-the-body-still-compi – onon15
@WilliamPursell - 绝对不是这个问题的重复。这里的问题不*与* main(void)有任何关系。 – Flexo