#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
int main(){
char greeting[]="Hello";
const char* p=greeting;
//p[0]='m';
greeting[0]='m';
printf("%s\n",p);
system("pause");
return 0;
}
程序的输出结果是:mello
注释的那句是错误的,因为是const char* ,指向的内容为常量不能修改,其实这句话不能这么说,应该说:不能通过p来修改p指向的内容,我们通过修改greeting[0]使输出的p的值发生改变,说明这块区域的内容是可以通过其他指针修改的。