当前位置:网站首页>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

边栏推荐
- [网络]跨区域网络的通信学习路由表的工作原理
- 毕马威中国:证券基金经营机构信息技术审计项目发现洞察
- Cell review: single cell methods in human microbiome research
- 基于MATLAB的函数拟合
- Thoroughly understand bit operations -- and (&), not (~), or (|), XOR (^)
- leetcode day3 超过经理收入的员工
- 软考中级(系统集成项目管理工程师)高频考点
- China's first chip stamp released: built-in 120um ultra-thin NFC chip
- Serial port receiving application ring buffer
- Digital filter design matlab
猜你喜欢

云计算笔记part.2——应用管理

Edge detection and connection of image segmentation realized by MATLAB

架构基本概念和架构本质

JS batch add event listening onclick this event delegate target currenttarget onmouseenter OnMouseOver

Servlet learning notes

Servlet学习笔记

Common APIs in string

High beam software has obtained Alibaba cloud product ecological integration certification, and is working with Alibaba cloud to build new cooperation

Leetcode Day1 score ranking

Prometheus deployment
随机推荐
Prometheus deployment
How many types of rain do you know?
Kubeedge releases white paper on cloud native edge computing threat model and security protection technology
Getting started with saltstack
[NPP installation plug-in]
[wechat applet development] page navigation and parameter transmission
adb remount of the / superblock failed: Permission denied
Getting started with enterprise distributed crawler framework
“中国网事·感动2022”二季度网络感动人物评选结果揭晓
leetcode day5 删除重复的电子邮箱
Handan, Hebei: expand grassroots employment space and help college graduates obtain employment
Source insight project import and use tutorial
String中常用的API
软考高级考试中有五大证书,哪个更值得考?
Basic knowledge of communication network 01
Edge detection and connection of image segmentation realized by MATLAB
Application skills of programming rising and falling edge instructions of botu 1200/1500plc (bool array)
河北邯郸:拓展基层就业空间 助力高校毕业生就业
The United States will provide $25billion in subsidies to encourage chip manufacturers such as Intel to move back to production lines
Redis笔记