当前位置:网站首页>[distinguish the meaning and usage of constant pointer and pointer constants const int * and int * const]
[distinguish the meaning and usage of constant pointer and pointer constants const int * and int * const]
2022-07-23 12:27:00 【Rest of life】
Want to find out this matter , First of all, the key is to understand :
const Belongs to modifier , The key is to see const The position of the decoration is there
1. Constant pointer
The so-called constant pointer , Constant modifier Const At the front : Such as Const int *a
here const Modification is int, and int Defines an integer value
therefore a The object that is pointed to value Cannot pass a To modify the , however You can give a To assign a value , Make it point to different objects
eg:
const int *a ;
const int b = 1;
int c = 1;
a = &b //ok additional : Note that you can't pass a To modify the b value
a = &c //ok additional : although c Itself is not a constant
*a = 2 //error That's the topic , Can not be modified through a The object value pointed to , Finally, give value The object is c**, So it can't pass a To modify the c value .
2. constant pointer
The so-called pointer constant , Is that the pointer is at the front Such as :Int * const a
here const Modification is a ,a It represents a Pointer address
Therefore, it cannot be assigned to a Other address values , But it can be modified a The value of the point
It's a little different cont int *a The opposite means , No more examples
eg:
Int * const a ;
const int b = 1;
int c = 1;
a = &b //OK First definition , The pointer can point to any variable
a = &c //error a The pointer has pointed to b Variable , So you can't point to other
*a = 2 //OK This means adopt The pointer a To modify the b Variable Value , therefore b Variable from previous 1 become 2
边栏推荐
- 保存实质审查请求书出现Schema校验失败的解决方法
- Tips for using textviewdidchange of uitextview
- 【AUTOSAR COM 3.信号的收发流程TX/RX】
- Practical convolution correlation trick
- ARM架构与编程7--异常与中断(基于百问网ARM架构与编程教程视频)
- 论文解读:《Deep-4mcw2v: 基于序列的预测器用于识别大肠桿菌中的 N4- 甲基胞嘧啶(4mC)位点》
- Data analysis (I)
- Interpretation of the paper: recognition of enhancer promoter interactions with neural networks based on pre trained DNA vectors and attention mechanisms
- 线性规划之Google OR-Tools 简介与实战
- Using or tools to solve path planning problem (VRP)
猜你喜欢

单片机学习笔记4--GPIO(基于百问网STM32F103系列教程)

NLP natural language processing - Introduction to machine learning and natural language processing (2)

Interpretation of the paper: using attention mechanism to improve the identification of N6 methyladenine sites in DNA

2021可信隐私计算高峰论坛暨数据安全产业峰会上百家争鸣

Analyze the pre integration of vio with less rigorous but logical mathematical theory

高分子物理考研概念及要点、考点总结

How to build a liquid cooling data center is supported by blue ocean brain liquid cooling technology

单片机学习笔记5--STM32时钟系统(基于百问网STM32F103系列教程)

论文解读:《利用注意力机制提高DNA的N6-甲基腺嘌呤位点的鉴定》

利用or-tools来求解带容量限制的路径规划问题(CVRP)
随机推荐
【AUTOSAR COM 4.Com服务层模块的介绍】
ARM架构与编程4--串口(基于百问网ARM架构与编程教程视频)
利用or-tools来求解路径规划问题(TSP)
Interpretation of the paper: develop and verify the deep learning system to classify the etiology of macular hole and predict the anatomical results
高分子合成工艺学
利用or-tools来求解路径规划问题(VRP)
液冷数据中心如何构建,蓝海大脑液冷技术保驾护航
论文解读:《基于预先训练的DNA载体和注意机制识别增强子-启动子与神经网络的相互作用》
【分清楚常量指针与指针常量 Const int *与Int * Const的含义与用法】
利用or-tools来求解带容量限制的路径规划问题(CVRP)
高等代数100道题及答案解析
C语言中,对柔性数组的理解
【AUTOSAR DCM 1.模块简介(DSL,DSD,DSP)】
In depth interpretation of Google or tools' complex scheduling program
Interpretation of the paper: DNA enhancer sequence recognition transformer structure based on Bert and two-dimensional convolutional neural network
NLP natural language processing - Introduction to machine learning and natural language processing (I)
Object class
Data analysis (I)
The green data center "counting from the east to the west" was fully launched
硬件知识2--协议类(基于百问网硬件操作大全视频教程)