当前位置:网站首页>写C语言的四个阶段
写C语言的四个阶段
2022-07-21 05:20:00 【¥阿拉伯王子¥】
先关注后白嫖,谢谢啦
写C语言程序的四个阶段
第一阶段 只写一个.c文件,在.c文件中只写一个main函数,把所有功能都放到main()中
第二阶段 只写一个.c文件,在.c文件中除了main函数以外还有其他的功能函数
函数的声明
函数的返回值类型 函数名(参数列表);//该位置的参数叫做形式参数
函数的实现(函数的定义)
函数的返回值类型 函数名(参数列表)//该位置的参数叫做形式参数
{
功能代码
}
函数的调用
函数名(参数);//该位置的参数叫做实际参数
函数名是函数的入口地址,函数名就是地址
形式参数接收实际参数的值
值传递
地址传递
第三阶段 多文件的方式实现项目
main.c 存放main函数,以及功能函数的调用
func.c 存放功能函数的实现
func.h 存放功能函数的声明,以及各种定义
makefile(Makefile) 存放编译规则
第四阶段 把.c文件做成库文件
动态库
静态库
二.makefile的简介
一个项目工程中的源文件不计其数,这些源文件按类型、功能、模块分别放在若干个目录中.
makefile定义了一系列的规则来指定,哪些文件需要先编译,哪些文件需要后编译.
哪些文件需要重新编译,甚至于进行更复杂的功能操作.
因为 makefile 就像一个Shell脚本一样,其中也可以执行操作系统的命令.
----------------------------------------
vim 打开多个文件
vim * -p 多文件以标签的形式打开
注意 : 不能打开过多的文件,否则vim会崩溃
用ctrl + alt + pgup / pgdn切换文件
----------------------------------------
三.C语言的作用域
1.空间的分布
C语言会把内存分为5个区域(栈区 堆区 常量区 全局区 代码区)
--------------------------------------------------------
./a.out->是由进程在执行可执行程序时分配存储空间
->4Kb(物理)->4Gb(虚拟空间)
1Gb Kernel(内核)
--------------------
3Gb 命令行参数和环境变量int main(int argc, char *argv[])
栈区
空白
堆区
静态区(全局区)未初始化的(系统默认会初始化成0)
静态区(全局区)已初始化的
常量区(RO DATA)只读的区域
代码区
栈区 不需要程序员来管理,自己开辟,自己释放
堆区 需要程序员来管理,手动开辟,手动释放(malloc realloc zalloc free)
静态区 全局变量/static关键字修饰的变量
常量区 read only(只读)
代码区 程序员没有办法管理
2.全局变量和局部变量
局部变量
在某个函数内部或者程序块内部定义的变量叫做局部变量
局部变量只能在该函数的内部 或者 该程序块的内部使用
局部变量在函数外部是不可知的
全局变量
全局变量是定义在函数外部的,通常写到程序的顶部
全局变量在整个程序中生命周期都是有效的
在任意函数的内部都可以访问全局变量
注意:
全局变量和局部变量可以同名
如果出现了同名的情况,那么在执行函数时优先使用局部变量,
在该函数中全局变量被屏蔽了
边栏推荐
- Class inheritance experiment report
- How can app testing ensure multi model coverage?
- Oracle database storage experiment management
- LVM disk multi partition expansion (fdisk, vgdata, lvdata, DF, resize2fs, lvextend, partprobe)
- Frequently asked interview questions in software testing [2]
- The communication process and principle of peer-to-peer host are very simple
- Centos7配置MySQL多实例
- Database dormitory management system
- JMeter's BeanShell generates random Chinese characters
- Using disassembly debugging and complement to explain 0x80000000 / -1 shaping output exception inconsistency
猜你喜欢
Mysql/sql server connects to the database through JDBC to add, delete, modify and query
Newly released yolov5 visual actual combat project (1)
JMeter之读响应求头的信息/获取请求头
[rviz2] error occurs when importing URDF model: could not load resource XXX, unable to open file XXX, error retrieving file XXX
Does Navicat 16 support native Apple silicon M1 chips| Apple user must read
[infrastructure] [flink] Flink / Flink CDC code to achieve business access
What if win7 system forgets its login password? (without startup disk)
JDBC connection / operation database of JMeter
Follow the guidelines and improve yourself quickly: how to quickly turn functional testing to automated testing
Take you to easily decrypt the white box test and (Demo detailed explanation)
随机推荐
How to write the use case of APP login function?
How to test insert and update statements before execution
JFrame needs to be resized before it can be displayed. The setbounds() method in JPanel does not work
Markdown and idea shortcut keys
LAMP架构——mysql路由器(读写分离器)
Zabbix+分布式数据库TiDB实现分布式数据库监控
JMeter aggregation Report
Atomic quotation to solve ABA problem
Importance of database monitoring
Vote | choose the database you want Navicat to support
JMeter之响应断言
[infrastructure] [flink] Flink / Flink CDC code to achieve business access
[email protected] interactive
Video 36 Chapter 13
View 2
Encapsulation des machines virtuelles
Quickly solve the problem that the computer wireless network cannot be connected
搭建服务器内网yum仓库
Solutions to the situation that some software cannot start and start automatically (solved)
Deployment of three centers in two places