c - 为什么这段代码在没有 int main() 的情况下运行
问题描述
#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;
}
解决方案
这是因为您使用的是 k&r 语法。
您不使用 ANSI C 语法。
推荐阅读
- c - 计算和打印矩阵的对角线之和
- javascript - 如何在 Angular 中使用 addEventListener 和 postMessage?
- php - 如何将日期、时间和值从单选按钮放入数据库
- c# - 逐个像素地动态绘制和显示,有一些延迟
- npm - 如何从 Nexus oss 代理获取依赖于 github 项目的 npm 包
- django - Django 测试 - 发送包含整数的数组数组
- android - 在 android 中使用改造登录
- json - 我如何在 nunjuncks 中乘以数据?
- swift - 为什么不能在swift中将可变参数标记为inout?
- vue.js - Vue Js 2 / Vue-CLI 3 / 托管时显示空白页