l*********r 发帖数: 674 | 1 void f(void)
{
char * p = "wikipedia";
p[0] = 'W'; // undefined behaviour
} | g**u 发帖数: 583 | 2 because we can not modify the content by using this pointer p; In fact, p is
pointing a constant string. and it is stored in data segment if I remember
right.
if you want to change the value, you will define if char [] p="...."; | t****t 发帖数: 387 | 3 c/c++ 里面
char a[] 和 char* b
其中a,b虽然很像,但是不一样
不知道为什么 | b******y 发帖数: 203 | 4 the string is stored in the program code segmentation, which can't be
modified.
【在 l*********r 的大作中提到】 : void f(void) : { : char * p = "wikipedia"; : p[0] = 'W'; // undefined behaviour : }
|
|