当前位置:网站首页>First knowledge of C language - why does every C program have a main function
First knowledge of C language - why does every C program have a main function
2022-07-27 05:37:00 【yin_ Yin】
We're writing C When you program, you will find that every program has one main function , Why is that ? every last C Are all procedures necessary ?
The answer is : Yes !!!
main function , Also called principal function , Is the starting point of program execution ,main Relatively speaking , Just as the tone of phonology theory is overtone , Overtone is division in program main Other functions besides , A pattern that caters to people's way of thinking rather than necessarily . There are masters and there are times , The implementation is clear , It can modularize the program and realize a closed whole .
In any one C In the program ,main Functions are essential ,main Function is the only entry of the program , in other words , Program runtime , First of all, from the main The function starts executing .
Look at this code :
#include <stdio.h>
int main()
{
int n = 0;
int count = 0;
scanf("%d", &n);
if (n < 12)
count = 2;
else
count = n / 12 * 4 + 2;
printf("%d\n", count);
return 0;
}

3. At the same time, we should pay attention to one C The program must have and can only have one main function , If there are more than one in a program main function , Then something must go wrong .
#include <stdio.h>
int main()
{
return 0;
}
int main()
{
int a = 0;
printf("%d\n", a);
return 0;
}

边栏推荐
- Trying to evolve_ My first CSDN blog
- 后台用户管理展示添加功能实现
- Promise的理解,以及它的实例方法
- 函数和箭头函数
- 背景图片相关应用-铺满,自适应
- C语言初阶——分支语句(if,switch)
- Source code of document type full-text retrieval knowledge base management system
- Xiaomi mall project_ register
- Student management system
- [codeworks round 801 div2 D tree queries] tree greedy conclusion
猜你喜欢

pytorch安装新坑

Flask请求数据获取与响应

上传七牛云的方法

JS中apply、call、bind的区别

Flask框架创建项目初期总结

初识C语言——初识指针

Sharing force buckle-189. Three solutions of rotation array

Hi3516DV300环境搭建

Li Hongyi machine learning team learning punch in activity day05 --- skills of network design

Li Hongyi machine learning team learning punch in activity day02 --- return
随机推荐
Program environment and preprocessing (Part 2): define, undef, command line compilation, conditional compilation, file inclusion (super full collation, recommended collection!!!
2021 Niuke multi school training camp 5 (question b)
How to view the evaluation of tutors
Pytorch data type and numpy data are mutually transformed
数据库迁移报错解决
分享一道关于变量的选择题(内含全局变量、局部变量、变量的作用域、生命周期知识点)
Hi3516dv300 environment setup
商品图片的管理
SQL (MySQL) rookie tutorial knowledge
mysql 取消外键关联约束
How to get started quickly and strengthen learning?
订单系统功能实现
异步数据-短信验证码
Introduction of C language base conversion and original complement inverse code point operation
Day3 ---Flask 状态保持,异常处理与请求钩子
Li Hongyi machine learning team learning punch in activity day01 --- introduction to machine learning
node 安装调试
SQL database → constraint → design → multi table query → transaction
Time complexity and space complexity
时间复杂度与空间复杂度