当前位置:网站首页>Embedded C first learning notes
Embedded C first learning notes
2022-06-26 01:16:00 【m0_ forty-six million three hundred and twenty-one thousand one】
1. An operation ( Binary operation )
(1) And &
If both values are 1 Then for 1, Otherwise 0
(2) or |
If one or both of the two values is 1 Then for 1, All two are 0 by 0
(3) Exclusive or ^
The two bits are different , The result is 1, Otherwise, the result is 0
(4) Take the opposite , Bitwise non ~
Operate on a number , Contraposition ,0 become 1,1 become 0
(5) Move left <<
The data being manipulated << Shifted number , Move left and the right will be empty , repair 0
(6) Move right >>
The number to be manipulated >> Shifted number , Move right and fill left 0, The leftmost digit of the unsigned is 0, The leftmost sign is 1
2. Static variables static
Reference resources :https://blog.csdn.net/guotianqing/article/details/79828100
#include <stdio.h>
void fn(void)
{
int n = 10;
printf("n=%d\n", n);
n++;
printf("n++=%d\n", n);
}
void fn_static(void)
{
static int n = 10;
printf("static n=%d\n", n);
n++;
printf("n++=%d\n", n);
}
int main(void)
{
fn();
printf("--------------------\n");
fn_static();
printf("--------------------\n");
fn();
printf("--------------------\n");
fn_static();
return 0;
}
Running results :
-> % ./a.out
n=10
n++=11
--------------------
static n=10
n++=11
--------------------
n=10
n++=11
--------------------
static n=11
n++=12
You can find two calls fn_static() Output when n Values change , Instead of using satic Function of ,n The value will not change .
3. Global variables extern
about extern function , Used in front of variables . In the variables of each individual file , Use extern Represents that this variable has been defined in other files , You can use variables from other files directly .
Reference material :https://www.cnblogs.com/0zcl/p/6082834.html
4. keyword const
const Chinese translation is generally constant , You can modify variables , The pointer , Array , Function parameters, etc .
You can modify variables 、 Array 、 The pointer 、 Function parameter
for example :
const int i = 5;
namely i Read only , Non modifiable , If it is copied again, an error will be reported , It can also be written as int const i = 5;
Reference material :https://baijiahao.baidu.com/s?id=1655909468895829791&wfr=spider&for=pc
边栏推荐
- 随便画画的
- 关于HC-12无线射频模块使用
- 数组中的第K个最大元素
- C disk cleaning strategy of win10 system
- The maze of God's perspective in robot vision
- 马斯克 VS 乔布斯,谁是21世纪最伟大的创业家
- Px4 system terminal for pixhawk
- Using redis database as cache in Django
- Electronic training.
- Etcd database source code analysis -- inter cluster network layer server interface
猜你喜欢

Redis的安装及启动

Implementation notes of least square fitting conic in stm32

halcon之区域:多种区域(Region)生成(4)

About the use of hc-12 radio frequency module

新库上线 | CnOpenDataA股上市公司IPO申报发行文本数据

Black box test - decision table method of test cases

C # operate with MySQL

Endnote IEEE Transactions on industrial electronics/tie/tpel reference format template

100ask seven day IOT training camp learning notes - bare metal program framework design

Modelsim simulation FFT core cannot be simulated solution (qsys)
随机推荐
About EF page turning query database
Daily question: the difference between threads and processes
卡通shader
数据分析——切片器、数据透视表与数据透视图(职场必备)
Typescript for Web Learning
Flex & Bison 开始
经典面试题之老鼠试药与汉明码
同花顺软件买股票进行交易安全吗?怎么开户买股票
关于HC-12无线射频模块使用
2022年电气试验考试试题模拟考试平台操作
超详细SSM框架实现增删改查功能项目整体流程
Solution to MySQL error code 2003
Installation and startup of redis
ETCD数据库源码分析——集群间网络层服务端接口
ADC acquisition noise and comparison between RMS filter and Kalman filter
idea配置
Essence and thoughts of 30 lectures on product thinking
信息收集的利器,Google骇客语法
每日一问:线程和进程的区别
Dgus new upgrade: fully support digital video playback function