当前位置:网站首页>【笔记】C语言数组指针、结构体+二维数组指针小记
【笔记】C语言数组指针、结构体+二维数组指针小记
2022-06-10 13:31:00 【创客协会的阿蛋°】
在开发中 为了高效,往往使用一大片连续的数据空间,如:结构体,数组,二维数组,而这些组合在一起,又是一大片的空间,在一bin内存一寸金的单片机中,非常的珍贵,所以我们常常使用指针来进行操作,一个是对内存空间的高效利用,一个是代码的高效运行,还有一个是在不懂的人看来, 逼格十足!
数组小记
uint8_t Change[4];
Mask(&Change[sector],bit);
void Mask(uint8_t *mask, uint8_t bit)
{
*mask |= (1 << bit);
}
以上代码是利用了C语言数组的地址来操作的。
==&Change[sector]==是取数组Change的[sector]开头的起始地址,然后用uint8_t *mask指针指向这地址的开头,即对这个数组进行一系列的操作,相当于:
(uint8_t *mask)&Change[sector] == Change[sector] ;
指针指向的地址,即指针取这块地址的值,长度类型为uint8_t。
以此为拓展:
uint8_t Change[4];
Mask(Change,bit);
void Mask(uint8_t *mask, uint8_t bit)
{
*mask |= (1 << bit);
}
//即为对数组的Change[0]的首地址取值,操作*mask 即是对Change地址的操作。
//uint8_t中,当mask超过7以后,即对第Change[1]操作,以此类推。
我的笔记
因为是手写的,就不打字上来了,个人笔记而已,里面有用结构体+二维数组指针,以及ucosiii系统相关的一些内容,有耐心的人可以研究一下,做个记录,以后写代码可以这样子开发,虽然有点绕,但是很高效。


边栏推荐
- How to locate the hot problem of the game
- leetcode-56-合并区间
- Im instant messaging development: the underlying principle of process killed and app skills to deal with killed
- Copying and deleting files
- Kotlin练手,以登录为例,Anko简单使用
- Talk about message oriented middleware (1) and AMQP
- [operation tutorial] how to correctly use the Hikvision demo tool to configure the channel to go online?
- buuctf [Discuz]wooyun-2010-080723
- Pycharm安装详细教程
- 618 大促来袭,浅谈如何做好大促备战
猜你喜欢

32. Simple test of raspberry pie serial port communication and ultrasonic module ranging

How to locate the hot problem of the game

2022 ciscn preliminary PWN complete WP
![buuctf [PHP]XDebug RCE](/img/e2/bcae10e2051b7e9dce918bf87fdc05.png)
buuctf [PHP]XDebug RCE

将anaconda的bin目录加入PATH

苹果生产线迁离,说明5G工业互联、智能制造对中国制造帮助有限

Simple integration of client go gin six list watch two (about the improvement of RS, pod and deployment)

组装芯片难保竞争优势,痛定思痛的高通终于开始自研核心架构
![buuctf [Jupyter]notebook-rce](/img/fc/9c2047bdadb606b555e48f553fb1dd.png)
buuctf [Jupyter]notebook-rce

How does the API detect security configuration errors?
随机推荐
苹果生产线迁离,说明5G工业互联、智能制造对中国制造帮助有限
[Huang ah code] I cleaned the console of Google browser in this way
Can qiniu open an account? Can the security of securities companies be directly opened on the app
[deep learning 05] cross entropy loss function
Cardview usage and properties
十款好用跨浏览器测试工具分享,好物值得收藏
#yyds干货盘点# 解决剑指offer:跳台阶扩展问题
Google Earth Engine(GEE)——利用MODIS 的叶面积指数影像掩膜dem批量下载
leetcode-56-合并区间
TabLayout 使用详解(修改文字大小、下划线样式等)
eKuiper Newsletter 2022-05|protobuf 编解码支持、可视化拖拽编写规则
10、 Application of state machine model (cellular automata; gdb/rr/perf; code verification tool)
Shell Encyclopedia
High performance practical Alibaba sentinel notes, in-depth restoration of Alibaba micro service high concurrency scheme
Typescript introductory notes (personal)
3. web page development tool vs Code
Ten easy-to-use cross browser testing tools to share, good things worth collecting
im即时通讯开发:进程被杀底层原理、APP应对被杀技巧
「大模型」之所短,「知识图谱」之所长
From "chemist" to developer, from Oracle to tdengine, two important choices in my life