当前位置:网站首页>Constant pointer, pointer constant
Constant pointer, pointer constant
2022-07-24 10:21:00 【A fool riding the wind and waves】
C Constant pointers in languages 、 Pointer constant in lua Application in
A constant pointer is a pointer to a constant , There are two ways to define it .
const int* n;
int const* n;
We need to pay attention to two points :
1、 Constant pointer means that the value of a variable cannot be changed through this pointer , But you can still change the value of the variable through other references .
int a=5;
const int* n=&a;
a=6;
2、 The value that the constant pointer points to cannot be changed , But that doesn't mean the pointer itself can't change , Constant pointers can point to other addresses .
int a=5;
int b=6;
const int* n=&a;
n=&b;
Pointer constant means that the pointer itself is a constant , Can't point to another address , It is written as follows :
int*const n;
It should be noted that , The address that the pointer constant points to cannot be changed , But the value stored in the address can be changed , It can be modified by other pointers to address change .
int a=5;
int*p=&a;
int* const n=&a;
*p=8;
The key to distinguish a constant pointer from a pointer constant is the position of the asterisk , We use the asterisk as the dividing line , If const To the left of the asterisk , Is a constant pointer , If const To the right of the asterisk is the pointer constant . If we read the asterisk as ‘ The pointer ’, take const pronounce as ‘ Constant ’ Words , The content is just in line with .int const * n; It's a constant pointer ,int *const n; It's a pointer constant .
Constant pointer to constant
const int* const a;
It's a combination of the two , The position that the pointer points to cannot be changed and the value of the variable cannot be changed through this pointer , But you can still change the value of the variable through other normal pointers .
const int* const luaX_tokens [];
stay lua In the source code, a constant array is implemented in this way , Defines a constant pointer to this constant array .
边栏推荐
- 【二叉树先导】树的概念和表示方法
- [STM32 learning] (12) STM32 realizes LCD1602 simple static reality
- Arduino drive Lora module node
- zoj-Swordfish-2022-5-6
- unity中物体z旋转同步面板上的数值
- Jenkins deploys the project and prompts that the module package defined by him cannot be found
- 图模型2--2022-5-13
- NiO knowledge points
- When the hot tea is out of stock, what does the new tea drink rely on to continue its life?
- CMS vulnerability recurrence - foreground arbitrary user password modification vulnerability
猜你喜欢

The best time to buy and sell stocks Ⅲ (leetcode-123)

Will not be rejected! Learn the distributed architecture notes sorted out by Alibaba Daniel in 35 days, with a salary increase of 20K

Websocket 协议解读-RFC6455
![[STM32 learning] (13) STM32 realizes ultrasonic ranging (hc-sr04)](/img/6e/b7cf7a8e3296e29d61a0626e3793ea.png)
[STM32 learning] (13) STM32 realizes ultrasonic ranging (hc-sr04)

Ask you to build a small program server
![[STM32 learning] (22) STM32 realizes 360 degree rotary encoder](/img/8e/fb036296ec3aff5e60acee5018943c.png)
[STM32 learning] (22) STM32 realizes 360 degree rotary encoder
![[STM32 learning] (18) STM32 realizes LCD12864 display - parallel implementation of 8-bit bus](/img/6b/b49b9e7fff62026a4818561d79fe3f.png)
[STM32 learning] (18) STM32 realizes LCD12864 display - parallel implementation of 8-bit bus
![[STM32 learning] (12) STM32 realizes LCD1602 simple static reality](/img/78/954ebaae0cce5d9387e7032fa85e60.png)
[STM32 learning] (12) STM32 realizes LCD1602 simple static reality

二叉树、二叉树排序树的实现及遍历

Jenkins deploys the project and prompts that the module package defined by him cannot be found
随机推荐
Notes on using setupproxy
zoj1137+作业1--2022年5月28日
脚手架内各文件配置说明、组件化开发步骤
Sub query of multi table query_ Single row and single column
Analysis of Kube proxy IPVS mode
Raspberry Pie: serial port login does not display print information
[STM32 learning] (16) STM32 realizes LCD1602 display (74HC595 drive) - 4-bit bus
Build a live broadcast platform based on webrtc
How to solve the problem of robot positioning and navigation in large indoor scenes with low-cost solutions?
The best time to buy and sell stocks (leetcode-121)
zoj-Swordfish-2022-5-6
关联规则--2022年7月10日
AttributeError: module ‘sipbuild. api‘ has no attribute ‘prepare_ metadata_ for_ build_ wheel‘
[STM32 learning] (12) STM32 realizes LCD1602 simple static reality
Kotlin advanced
Can the "self-help master" who has survived the economic crisis twice continue to laugh this time?
Dr. water 3
Zoj1137+ operation 1 -- May 28, 2022
WEB安全基础 - - -文件上传(文件上传绕过)
Simple parsing JSON strings with regular expressions