#include<iostream>
#include<cstdlib>
using namespace std;
void main(){
const char *p1="Hello";
cout<<"p1->"<<p1<<endl;
//p1[2]='a';
p1="Hello World";
cout<<"p1->"<<p1<<endl;
char * const p2="C++";
cout<<"p2->"<<p2<<endl;
p2[1]=p2[2]='p';
cout<<"p2->"<<p2<<endl;
//p2=p1;
const char *const p3="constpoint";
cout<<"p3->"<<p3<<endl;
//p3[3]='q';
//p3=p1;
system("pause");
}
------------------------------------
上面代码通过编译,但exe程序运行出错。为什么呢? |