【发布时间】:2021-10-09 09:22:51
【问题描述】:
#include <stdio.h>
int main()
struct books
{
char title[50];
char author[50];
char sub[100];
int b_id;
};
//here int main should be used but not still the code runs fine why??
{
struct books b1={"48lop","rg","sh",288017};
printf("%s\n",b1.title);
printf("%s\n",b1.author);
printf("%s\n",b1.sub);
printf("%d",b1.b_id);
return 0;
}
【问题讨论】:
-
在 函数签名 和函数体之间的旧式(如 1989 年之前)参数(有点,你的 main 没有参数)。
-
你是如何运行它的? gcc 和 clang 都不会编译这段代码,你应该得到一个编译错误。
-
@ifalkau 编译:ideone.com/G9gssk OT:旧式参数(AKA K&R 风格)将在下一个标准中删除。
-
明明有
int main(),你为什么说它没有?