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

边栏推荐
- 【经验之谈】关于维修电子设备的几点建议和经验
- [network] cross area network communication learning classification and calculation of IPv4 address
- NPM installing and uninstalling global packages
- Handan, Hebei: expand grassroots employment space and help college graduates obtain employment
- MySQL8 Encrypting InnoDB Tablespaces
- adb remount of the / superblock failed: Permission denied
- Leetcode Day1 score ranking
- Special draft of Mir | common sense knowledge and reasoning: representation, acquisition and application (deadline on October 31)
- Kubeedge releases white paper on cloud native edge computing threat model and security protection technology
- leetcode day1 分数排名
猜你喜欢

How many types of rain do you know?

Netcoreapi operation excel table

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

English Translation Spanish - batch English Translation Spanish tools free of charge

Saltstack system initialization

Cell review: single cell methods in human microbiome research

基于MATLAB的函数拟合

How does app automated testing achieve H5 testing

How to write the SQL statement of time to date?

Android-第十三节03xUtils-数据库框架(增删改查)详解
随机推荐
MySQL8 Encrypting InnoDB Tablespaces
Why is there no log output in the telnet login interface?
What parameters should be passed in calling integer or character array functions
There are five certificates in the soft examination advanced examination, which is more worth taking?
What is the process of swing event processing?
With the help of panel industry innovation, will FPGA become the best choice for TCON?
The results of the second quarter online moving people selection of "China Internet · moving 2022" were announced
Implementation of markdown editor in editor.md
[NPP installation plug-in]
String中常用的API
MySQL8 Status Variables: Internal Temporary Tables and Files
Leetcode Day1 score ranking
MySQL8 基于clone创建主从复制
Codeignier framework implements restful API interface programming
CDGA|工业互联网行业怎么做好数据治理?
云计算笔记part.1——系统管理
Getting started with enterprise distributed crawler framework
English translation Italian - batch English translation Italian tools free of charge
MySQL8 tmp_ table_ Size and Max_ heap_ table_ size
Android section 13 03xutils detailed explanation of database framework (addition, deletion and modification)