#include <iostream>
using namespace std;
int main()
{
const char *t1="hello";
char test[]="world";
char *const t2=test;
t1="world";
// t2="hello"; //编译错误,常指针不能赋予新的值,即不能赋予新的地址
// t1[1]='n'; //编译错误,指针指向常量,所指向的值不能被修改
t2[2]='n';
cout<<t2<<endl;
cout<<t1<<endl;
return 0;
}
运行结果:
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。