当前位置:网站首页>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
边栏推荐
- Swiftui 4 new features complete toggle and mixed toggle multiple binding components
- 如果浏览器被意外关闭,react怎么缓存用户填写的表单?
- 目標檢測——Yolo系列
- Slf4j打印异常的堆栈信息
- 8K HDR!| Hevc hard solution for chromium - principle / Measurement Guide
- PWN攻防世界cgpwn2
- Stack overflow 2022 developer survey: where is the industry going?
- 架构师毕业总结
- 宅男壁纸大全微信小程序源码-带动态壁纸支持多种流量主
- Uniapp uses Tencent map to select points without window monitoring to return users' location information. How to deal with it
猜你喜欢

leetcode刷题:栈与队列03(有效的括号)

合成大西瓜小游戏微信小程序源码/微信游戏小程序源码

【Leetcode】最大连续1的个数

8K HDR!| Hevc hard solution for chromium - principle / Measurement Guide

leetcode刷题:二叉树01(二叉树的前序遍历)

收藏:存储知识全面总结

Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results

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

Win11 how to hide the taskbar? Win11 method to hide the taskbar

Penetration tools - trustedsec's penetration testing framework (PTF)
随机推荐
升级版手机检测微信工具小程序源码-支持多种流量主模式
朋友圈社区程序源码分享
Is it safe to open an account online? Can a novice open a stock trading account.
多个张量与多个卷积核做卷积运算的输出结果
On the next generation entrance of the metauniverse -- the implementation of brain computer interface
编程英语生词笔记本
300 linear algebra Lecture 4 linear equations
What if win11 can't pause the update? Win11 pause update is gray. How to solve it?
How can I know if I want to get the preferential link of stock account opening? Is it safe to open an account online?
联想电脑怎么连接蓝牙耳机?
What if the win11 shortcut key switching input method doesn't respond? Shortcut key switching input method does not respond
喜马拉雅自研网关架构演进过程
Entering Ruxin Town, digital intelligence transformation connects "future community"
EMC-电路保护器件-防浪涌及冲击电流用
Uniapp uses Tencent map to select points without window monitoring to return users' location information. How to deal with it
BPR(贝叶斯个性化排序)
杰理之关于长按开机检测抬起问题【篇】
浏览器tab页之间的通信
杰理之烧录都使用 VBAT 供电,供电电压 4.2V【篇】
宅男壁纸大全微信小程序源码-带动态壁纸支持多种流量主