如下所示,当c语言main函数,返回值是void时,有提醒:return type of 'main' is not 'int' [-Wmain]
#include <stdio.h>
//warnning:return type of 'main' is not 'int' [-Wmain]
void main(){
printf("hello world!");
return 0;}正确写法如下:
#include <stdio.h>
int main(){
printf("hello,c!");
return 0;
}虽然能运行,但是看着不爽我就去查了下。发现c标准里规定main返回值必须为int。
以下是stackoverflow的一些回答:
What should main() return in C and C++?
Hello.c: In function ‘main’: Hello.c:13: warning: return type of ‘main’ is not ‘int’? [duplicate]
版权声明:本文为jh0703原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。