当前位置:网站首页>【笔记】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系统相关的一些内容,有耐心的人可以研究一下,做个记录,以后写代码可以这样子开发,虽然有点绕,但是很高效。


边栏推荐
- BottomNavigationView使用,配合ViewPager、修改图标大小、去掉文字等
- Typescript introductory notes (personal)
- 618 大促来袭,浅谈如何做好大促备战
- TabLayout 使用详解(修改文字大小、下划线样式等)
- Pychart installation tutorial
- Neuron Newsletter 2022-05|新增 2 個南向驅動和 1 個北向應用、Modbus TCP 實現定制擴展
- Tablayout usage details (modify text size, underline style, etc.)
- 常识,神经元数量,小鼠的脑内神经元大约在7000万个、人类约有860亿个
- H. 265 introduction to coding principles
- 如何定位游戏发热问题
猜你喜欢

If I write the for loop again, I will hammer myself

WT2003H4-16S 语音芯片按键录音及播放应用解析
![buuctf [Discuz]wooyun-2010-080723](/img/b9/d63c9c638ff7c390c490d6fd5eafd1.png)
buuctf [Discuz]wooyun-2010-080723

新功能|Mail GPU Counter模块新增GPU图元处理和GPU Shader Cycles

Solve the problem of cross sea high concurrent crash? so easy

解决VMWareStation安装 tools 时 D:\setup.exe 找不到的问题
![Buuctf [glassfish] arbitrary file reading](/img/37/e3c127f2f2ba97c5ca0b6cf01cf9ab.png)
Buuctf [glassfish] arbitrary file reading

MMdetection增加评估指标precision
![[Netease Yunxin] in depth analysis of the design of](/img/17/7c0b7db01310f8dd31e9021f8d5516.png)
[Netease Yunxin] in depth analysis of the design of "circle group" relationship system | series of articles on "circle group" technology

Idea custom configuration link Nacos
随机推荐
将anaconda的bin目录加入PATH
Final exam - Principles of compilation
Google Earth Engine(GEE)——利用MODIS 的叶面积指数影像掩膜dem批量下载
[Multisim Simulation] differential amplifier circuit 2
NanoMQ Newsletter 2022-05|v0.8.0 发布,新增 WebHook 拓展接口和连接认证 API
[technical analysis] discuss the production process and technology of big world games - preliminary process
什么是基因的p值?
【Multisim仿真】差分放大电路2
启牛能开户吗,在APP上可以直接开通券商安全吗
What are the common automated test frameworks? Shanghai software testing company Amway
32. Simple test of raspberry pie serial port communication and ultrasonic module ranging
智慧校园安全通道及视频监控解决方案
Neuron newsletter 2022-05 | add 2 southbound drivers and 1 northbound application, and realize customized extension with Modbus TCP
新功能|Mail GPU Counter模块新增GPU图元处理和GPU Shader Cycles
[deep learning] the credit card fraud anomaly detection based on the deep learning autoencoder is very effective
Nanomq newsletter 2022-05 | release of V0.8.0, new webhook extension interface and connection authentication API
Google Earth Engine(GEE)——基于s2影像的实时全球10米土地利用/土地覆盖(LULC)数据集
In depth analysis of "circle group" relationship system design | series of articles on "circle group" technology
BottomNavigationView使用,配合ViewPager、修改图标大小、去掉文字等
RecyclerView多布局写法,“我的”、“个人中心” 页面经典写法演示