当前位置:网站首页>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
边栏推荐
- 案例:绘制Matplotlib动态图
- C another new class is ICO? And app Use of config
- 远程增量同步神器rsync
- The cache page stores the initial parameters after the route jump under the react + router framework
- Electronic training.
- 2022资料员-通用基础(资料员)考试模拟100题及在线模拟考试
- Native DOM vs. virtual DOM
- Msp430f5529lp official board (red) can not debug the problem
- Flex & Bison 开始
- Chapter VI exercises (678) [microcomputer principles] [exercises]
猜你喜欢

多接口调用,使用Promise.all、Promise.race和Promise.any

Endnote IEEE TRANSACTIONS ON INDUSTRIAL ELECTRONICS/TIE/TPEL 参考文献格式模板

生信周刊第33期

Technical introduction - detailed explanation of chip manufacturing process

From query database performance optimization to redis cache - talk about cache penetration, avalanche and breakdown

Typescript for Web Learning

C # operate with MySQL

下载安装Flume

Msp430f5529lp official board (red) can not debug the problem

The maze of God's perspective in robot vision
随机推荐
Optimized three-dimensional space positioning method and its fast implementation in C language
Chapter VI exercises (678) [microcomputer principles] [exercises]
Black box test - decision table method of test cases
基金开户安全吗?有没有什么风险?
halcon之区域:多种区域(Region)生成(4)
返回值为Object型方法调用equals()
2022年电气试验考试试题模拟考试平台操作
Template engine - FreeMarker first experience
Simple deepclone
. Net using access 2010 database
数组中的第K个最大元素
Data analysis slicer, PivotTable and PivotChart (necessary in the workplace)
在线小工具分享(不定时更新,当前数量:2)
Web information collection, naked runners on the Internet
如何有效地推广产品
The kth largest element in the array
数据分析——切片器、数据透视表与数据透视图(职场必备)
Classic interview questions: mouse drug test and Hamming code
Unified gateway
Is it safe to open a fund account? Are there any risks?