当前位置:网站首页>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】最大连续1的个数
- leetcode刷题:二叉树02(二叉树的中序遍历)
- 极客DIY开源方案分享——数字幅频均衡功率放大器设计(实用的嵌入式电子设计作品软硬件综合实践)
- Importance of EDA tools to chip industry knowledge popularization
- 杰理之、产线装配环节【篇】
- 杰理之关于长按开机检测抬起问题【篇】
- 天气预报小程序源码 天气类微信小程序源码
- 架构师毕业总结
- [multithreading] realize the singleton mode (hungry and lazy) realize the thread safe singleton mode (double validation lock)
- 强大的万年历微信小程序源码-支持多做流量主模式
猜你喜欢
Niuke programming question -- must brush the string of 101 (brush the question efficiently, draw inferences from one instance)
STC 32-bit 8051 single chip microcomputer development example tutorial II i/o working mode and its configuration
编程英语生词笔记本
新版Free手机、PC、平板、笔记本四端网站缩略展示图在线一键生成网站源码
Practical project notes (I) -- creation of virtual machine
人才近悦远来,望城区夯实“强省会”智力底座
What if the win11 shortcut key switching input method doesn't respond? Shortcut key switching input method does not respond
leetcode刷题:栈与队列06(前 K 个高频元素)
新版图解网络PDF即将发布
leetcode刷题:栈与队列03(有效的括号)
随机推荐
【Leetcode】最大连续1的个数
合成大西瓜小游戏微信小程序源码/微信游戏小程序源码
4. 对象映射 - Mapping.Mapstercover
编译原理复习笔记
Comprehensive evaluation and detailed inventory of high-quality note taking software (I) note, obsedian, remnote, flowus
多个张量与多个卷积核做卷积运算的输出结果
EDA工具对芯片产业的重要性知识科普
Penetration tools - trustedsec's penetration testing framework (PTF)
STC 32-bit 8051 single chip microcomputer development example tutorial II i/o working mode and its configuration
Internship: gradually moving towards project development
杰理之关于长按开机检测抬起问题【篇】
Slf4j打印异常的堆栈信息
人脸识别系统 —— OpenCV人脸检测
收藏:存储知识全面总结
What if the win11 shortcut key switching input method doesn't respond? Shortcut key switching input method does not respond
十三届蓝桥杯B组国赛
Review notes of Zhang Haifan in introduction to software engineering (Sixth Edition)
Test of NSI script
【Opencv450】HOG+SVM 与Hog+cascade进行行人检测
Is it safe to open an account online? Can a novice open a stock trading account.