当前位置:网站首页>The usage and difference of * and & in C language and the meaning of keywords static and volatile
The usage and difference of * and & in C language and the meaning of keywords static and volatile
2022-04-23 02:15:00 【childboi】
Catalog
C In language * And & The usage and difference of
keyword static and volatile Meaning and function of
C In language * And & The usage and difference of
c Define a (int a) Variables are ambiguous , In essence, it is to allocate a address space , There is a value in it .
To avoid ambiguity ,c Specifies the a Is the value ,&a Is the address space .
Pointer to an address .
here *a Represents the value stored in the address pointed to ,a It's the address that points to .
void tes(int *i){
*i=2;
}
int main(int argc, char *argv[]){
int a=4;
int* s = &a;
tes(s);
printf("%d\n",*s);
printf("%d\n",s);
}
The above code changes the incoming value through the incoming address , Output *s by 2,s For address .
keyword static and volatile Meaning and function of
static:
c In language static Keywords have two functions , First, file scope , The second is function scope .
File scope keyword static The role of is , With static Declared global variables 、 Functions must not be referenced by other files ;
static Another use is static variables inside functions , It will only be initialized once , And variables are stored in global data segments instead of function stacks , So its lifetime will last until the program exits .
Take the chestnut of callback function : although counting() The function calls itself back several times , But static integer variables count Not initialized every time , Instead, it is initialized only once , The purpose of counting is achieved .
volatile:
volatile English means changeable . stay C In language , One definition is volatile Variable means that this variable is likely to be changed unexpectedly , Therefore, we need to be careful . in other words , When the optimizer uses this variable, it must re
Read the value of this variable from virtual memory , Instead of using a backup stored in a register .
版权声明
本文为[childboi]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230209449666.html
边栏推荐
- Today will finally write system out. Println()
- Develop a chrome plug-in from 0 (2)
- RT_Thread自问自答
- 不断下沉的咖啡业,是虚假的繁荣还是破局的前夜?
- Find the largest number of two-dimensional arrays
- Numerical remapping method (remap)
- 每日一题(2022-04-21)——山羊拉丁文
- 89 logistic regression user portrait user response prediction
- Lighting LED of IAR embedded development stm32f103c8t6
- 011_ Redistemplate operation hash
猜你喜欢
Introduction to micro build low code zero Foundation (lesson 2)
用TensorFlow实现线性回归(包括过程中出现的问题及解决方法)
They are all intelligent in the whole house. What's the difference between aqara and homekit?
PTA: praise the crazy devil
002_Redis_String类型常见的操作命令
电源电路设计原来是这么回事
【2019-CVPR-3D人体姿态估计】Fast and Robust Multi-Person 3D Pose Estimation from Multiple Views
Latin goat (20204-2022) - daily question 1
Kubernetes cluster installation based on Kirin SP10 server version
easyswoole环境配置
随机推荐
Thinkphp内核开发盲盒商城源码v2.0 对接易支付/阿里云短信/七牛云存储
小程序 读取文件
arduino esp8266 网络升级 OTA
Arduino esp8266 network upgrade OTA
Analyze the advantages and disadvantages of tunnel proxy IP.
Introduction to esp32 Bluetooth controller API
Log4j2 configuration
leetcode:27. Remove element [count remove]
easyswoole环境配置
Leetcode39 combined sum
Flink real-time data warehouse project - Design and implementation of DWS layer
PTA: 浪漫倒影 [二叉树重建] [深度优先遍历]
SO库依赖问题
Easyswool environment configuration
LeetCode 283. Move zero (simple, array) Day12
【汇编语言】从最底层的角度理解“堆栈”
Talk about biology live broadcast: Dr. Wang Ziyuan, a lake view biology, exploring hepatitis B with gene therapy
C standard library - < time h>
【dpdk】10. Dpdk DNS learning notes
006_redis_jedis快速入门