当前位置:网站首页>2. Const pointer
2. Const pointer
2022-07-02 14:30:00 【Little BigUs】
const Qualifiers are used to mark a variable as read-only , But it's a little complicated when decorating pointers .
First ,const int *pa and int const *pa The effect is the same , These two are completely equivalent , This const Modification is *pa This whole , in other words *pa This whole is read-only , however pa( No addition *) It can be modified . The variable it points to can also be modified . for instance
int a = 100;
const int *pa = &a;
printf("%d\n",*pa);//100
a = 200;
printf("%d\n",*pa);//200
int a = 100;
int b = 200;
const int *pa = &a;
printf("%d\n",*pa);//100
pa = &b;
printf("%d\n",*pa);//200
int a = 100;
const int *pa = &a;
printf("%d\n",*pa);//100
*pa = 200;// Report errors ,*pa yes const Type , read-only
and int * const pa in pa It's also a pointer , But this const Modification is pa Instead of *pa This whole , in other words , At this time, you can use the *pa To modify the a The value of the , however pa It's immutable , That is to say pa Can only point to a 了 , You can't point him at b, because pa The value of is the address of the target it points to , This is read-only .
Of course we can use const int * const pa This format , In this way, it is pa and *pa All read-only .
边栏推荐
- Design and implementation of car query system based on php+mysql
- There is no solution to the decryption error of the remote user 'sa' and the service master password mapped from the remote server 'to the local user' (null) /sa '
- < schematic diagram of oral arithmetic exercise machine program development> oral arithmetic exercise machine / oral arithmetic treasure / children's math treasure / children's calculator LCD LCD driv
- 无主灯设计:如何让智能照明更加「智能」?
- Uniapp automated test learning
- 自定义事件,全局事件总线,消息订阅与发布,$nextTick
- Understanding of mongodb
- Golang quickly generates model and queryset of database tables
- Essential elements of science fiction 3D scenes - City
- Quick analysis: easy to share the Internet
猜你喜欢
![[development environment] Dell computer system reinstallation (download Dell OS recovery tool | use Dell OS recovery tool to make USB flash disk system | install system)](/img/e0/e9cb42f241a60995d4598ba6a1a2fe.jpg)
[development environment] Dell computer system reinstallation (download Dell OS recovery tool | use Dell OS recovery tool to make USB flash disk system | install system)

Fabric.js 自由绘制圆形

千元投影小明Q1 Pro和极米NEW Play谁更好?和哈趣K1比哪款配置更高?

Fabric.js 缩放画布

Fabric.js 上划线、中划线(删除线)、下划线

In 2021, the global TCB adapter revenue was about $93 million, and it is expected to reach $315.5 million in 2028

测试框架TestNG的使用(二):testNG xml的使用

What is erdma? Popular science cartoon illustration

<口算练习机 方案开发原理图>口算练习机/口算宝/儿童数学宝/儿童计算器 LCD液晶显示驱动IC-VK1621B,提供技术支持

Who is better, Qianyuan projection Xiaoming Q1 pro or Jimi new play? Which configuration is higher than haqu K1?
随机推荐
Multi rotor aircraft control using PID and LQR controllers
腾讯云 TStor 统一存储通过信通院首批文件存储基础能力评测
Fabric. Usage of JS eraser (including recovery function)
Qt原代码基本知识
How kaggle uses utility script
c# 水晶报表打印
Slashgear shares 2021 life changing technology products, which are somewhat unexpected
MySQL 45 lecture - learning from the actual battle of geek time MySQL 45 Lecture Notes - 04 | easy to understand index (Part 1)
由粒子加速器产生的反中子形成的白洞
Data consistency between redis and database
Tujia muniao meituan has a discount match in summer. Will it be fragrant if the threshold is low?
docker mysql
String matching problem
The evolution process of the correct implementation principle of redis distributed lock and the summary of redison's actual combat
Solve the problem that openocd fails to burn STM32 and cannot connect through SWD
< schéma de développement de la machine d'exercice oral > machine d'exercice oral / trésor d'exercice oral / trésor de mathématiques pour enfants / lecteur LCD de calculatrice pour enfants IC - vk1621
Yolov3 & yolov5 output result description
Fabric.js 缩放画布
Packet capturing tool Fiddler learning
Fabric.js 动态设置字号大小