当前位置:网站首页>Const pointer of C language and parameter passing of main function
Const pointer of C language and parameter passing of main function
2022-07-28 20:00:00 【Embedded Xiaobai aspires to be a boss】
- const Decorated pointer
- main Function arguments
1、const Decorated pointer
const: read-only
Used to modify variables , Use const Decorated variables can only be read , Cannot be modified
int a;// Storage and re stacking area
const int a;// Store in the stack area
Case study : Judge const Whether the modified variable is in the constant area

char str[30] = “hello”;// stay The stack area Opens the 30 Bytes of space
str[0] = ‘a’;

char *p = “hello”; p Store in stack area , “hello” Is a string constant , So in the constant area
*p = ‘a’;//error because “hello” Stored in the constant area , Cannot be modified

char str[30] = {0};
str = “hello”; //error str Is a constant
char *p = NULL;
p = “hello”;
const Decorated pointer :
int a = 10;
const int *p = &a;//const modification *p,*p Cannot be modified
int *const p = &a;//const Modification is p,p We can't change the direction of
const int *const p = &a;*p and p Can't be modified

summary :const Who is near , Just decorate who
const leave int near , Modification is *p
const leave * near , Modification is p
2、main Function arguments

边栏推荐
- 11、 学习MySQL UNION 操作符
- 软考中级(系统集成项目管理工程师)高频考点
- [网络]跨区域网络的通信学习路由表的工作原理
- Preliminary learning function (3rd blog)
- Concurrent programming, do you really understand?
- Deploy ZABBIX automatically with saltstack
- How does app automated testing achieve H5 testing
- Leetcode Day2 consecutive numbers
- Edge detection and connection of image segmentation realized by MATLAB
- Leetcode day3 find duplicate email addresses
猜你喜欢

Leetcode Day1 score ranking

KubeEdge发布云原生边缘计算威胁模型及安全防护技术白皮书

Know small and medium LAN WLAN

What parameters should be passed in calling integer or character array functions

Design of air combat game based on qtgui image interface

Common APIs in string

Idea properties file display \u solution of not displaying Chinese

克服“看牙恐惧”,我们用技术改变行业

How does app automated testing achieve H5 testing

Servlet学习笔记
随机推荐
Sprint for golden nine and silver ten, stay up at night for half a month, collect 1600 real interview questions from Android post of major manufacturers
2022年下半年系统集成项目管理工程师认证8月20日开班
How openocd directly downloads programs to STM32 board through stlink (solved)
adb remount of the / superblock failed: Permission denied
editor.md中markdown编辑器的实现
shared_ptr 和 make_shared 的使用
认识中小型局域网WLAN
The peak rate exceeds 2gbps! Qualcomm first passed 5g millimeter wave MIMO OTA test in China
[network] communication across regional networks learn how routing tables work
Oracle insert数据时字符串中有‘单引号问题
How to write the SQL statement of time to date?
数字图像理论知识(一)(个人浅析)
Source insight project import and use tutorial
Thoroughly understand bit operations -- and (&), not (~), or (|), XOR (^)
BeanFactory not initialized or already closed - call ‘refresh‘ before accessing beans via the Applic
There are five certificates in the soft examination advanced examination, which is more worth taking?
China's first chip stamp released: built-in 120um ultra-thin NFC chip
Leetcode Day5 delete duplicate email
Idea properties file display \u solution of not displaying Chinese
[网络]跨区域网络的通信学习IPv4地址的分类和计算