- const修饰的指针
- main函数传参
1、const修饰的指针
const:只读
用来修饰变量,使用const修饰的变量只能读,不能被修改
int a;//存放再栈区
const int a;//存放在栈区
案例:判断const修饰的变量有没有在常量区
char str[30] = “hello”;//在栈区开辟了30个字节的空间
str[0] = ‘a’;
const:只读
用来修饰变量,使用const修饰的变量只能读,不能被修改
int a;//存放再栈区
const int a;//存放在栈区
案例:判断const修饰的变量有没有在常量区
char str[30] = “hello”;//在栈区开辟了30个字节的空间
str[0] = ‘a’;