当前位置:网站首页>C中main函数的几种写法
C中main函数的几种写法
2022-07-01 20:20:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
1、最标准的写法
#include <stdio.h>
int main()
{
printf("Hello World! ");
return 0;
}2、把int 换成void
#include <stdio.h>
void main()
{
printf("Hello World! ");
return 0;
}3、不写int
#include <stdio.h>
main()
{
printf("Hello World! ");
return 0;
}4、不写return
#include <stdio.h>
int main()
{
printf("Hello World! ");
}以上四种写法均成功运行。
多种写法不报错的原因
- C语言最早的时候只是一种规范和标准(例如C89, C11等)
- 标准的推行需要各大厂商的支持和实施
- 而在支持的实施的时候由于各大厂商利益、理解等问题,导致了实施的标准不同,发生了变化
- Turbo C
- Visual C(VC)
- GNU C(GCC)
- 所以大家才会看到不同的书上书写的格式有所不同, 有的返回int,有的返回void,有的甚至没有返回值
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/147183.html原文链接:https://javaforall.cn
边栏推荐
猜你喜欢

leetcode刷题:二叉树02(二叉树的中序遍历)

Review notes of Zhang Haifan in introduction to software engineering (Sixth Edition)

芭比Q了!新上架的游戏APP,咋分析?

以飞地园区为样本,看雨花与韶山如何奏响长株潭一体化发展高歌

人才近悦远来,望城区夯实“强省会”智力底座

300 linear algebra Lecture 4 linear equations

杰理之、产线装配环节【篇】

EURA eurui E1000 series inverter uses PID to realize the relevant parameter setting and wiring of constant pressure water supply function

What if the win11 shortcut key switching input method doesn't respond? Shortcut key switching input method does not respond

开环和闭环是什么意思?
随机推荐
在技术升级中迎合消费者需求,安吉尔净水器“价值战”的竞争之道
升级版手机检测微信工具小程序源码-支持多种流量主模式
天气预报小程序源码 天气类微信小程序源码
Target detection - Yolo series
杰理之、产线装配环节【篇】
东哥套现,大佬隐退?
如何用OpenMesh创建一个四棱锥
PHP 读取ini或env类型配置
[multithreading] lock strategy
Face recognition system opencv face detection
Détection des cibles - série Yolo
Keras machine translation practice
目标检测——Yolo系列
MySQL数据库驱动(JDBC Driver)jar包下载
喜马拉雅自研网关架构演进过程
EURA eurui E1000 series inverter uses PID to realize the relevant parameter setting and wiring of constant pressure water supply function
杰理之蓝牙耳机品控和生产技巧【篇】
What else do you not know about new set()
Halcon知识:三维重构的一个尝试