int main() { char str[] = "hello world"; char sec[] = "code world"; const char *ptr1 = str; cout << ptr1 << endl; strcpy(str,"hi world"); cout << ptr1 << endl; ptr1 = sec;//直接改变指针指向 cout << ptr1 << endl; sec[0] = 'o'; cout << ptr1 << endl; ptr1[0] = 'a';//直接改变指针指向的值,报错 char ss[] = "good game"; char *const ptr2 = ss; cout << ptr2 << endl; ptr2[0] ='a';//直接改变指针指向的值 cout << ptr2 << endl; strcpy(ptr2, "last"); cout << ptr2 << endl; ss[0] = 'z'; cout << ptr2 << endl; ptr2 = sec;//直接改变指针指向,报错 system("pause"); }