当前位置:网站首页>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 .
边栏推荐
- Federated Search: all requirements in search
- uni-app中使用computed解决了tab切换中data()值显示的异常
- 由粒子加速器产生的反中子形成的白洞
- Pycharm连接远程服务器
- How kaggle uses utility script
- 自定义事件,全局事件总线,消息订阅与发布,$nextTick
- Slashgear shares 2021 life changing technology products, which are somewhat unexpected
- 测试框架TestNG的使用(二):testNG xml的使用
- 每天坚持20分钟go的基础二
- 抓包工具fiddler学习
猜你喜欢

Federated Search: all requirements in search
![[Hongke technology sharing] how to test DNS server: DNS performance and response time test](/img/f4/d8c21d6c33985fd6d819cd44c22c72.png)
[Hongke technology sharing] how to test DNS server: DNS performance and response time test

MySQL 45 lecture - learning from the actual battle of geek time MySQL 45 Lecture Notes - 04 | easy to understand index (Part 1)

Use of swagger

什么是 eRDMA?丨科普漫画图解

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 '

Yyds dry goods inventory software encryption lock function

Available solution development oral arithmetic training machine / math treasure / children's oral arithmetic treasure / intelligent math treasure LCD LCD driver ic-vk1622 (lqfp64 package), original te

2022家用投影仪首选!当贝F5强悍音画效果带来极致视听体验

每日学习3
随机推荐
Development and design of animation surrounding mall sales website based on php+mysql
Word frequency statistics & sorting
C crystal report printing
STM32-DAC实验&高频DAC输出测试
当贝投影4K激光投影X3 Pro获得一致好评:万元投影仪首选
2、const 型指针
路由(二)
Tencent cloud tstor unified storage passed the evaluation of the first batch of basic file storage capabilities of the ICT Institute
删除元素(带过渡动画)
2022家用投影仪首选!当贝F5强悍音画效果带来极致视听体验
抓包工具fiddler学习
全屋Wi-Fi:一个谁也解决不好的痛点?
Golang 快速生成数据库表的 model 和 queryset
Go operation redis
Multi rotor aircraft control using PID and LQR controllers
Fabric. JS free drawing ellipse
Data consistency between redis and database
NLA natural language analysis makes data analysis more intelligent
提示:SQL Server 阻止了对组件‘Ad Hoc Distributed Queries ‘的STATEMENT ‘OpenRowset/OpenDatasource“”
Penetrate the remote connection database through the Intranet