重複の可能性:
単純なCコードがセグメンテーション違反を受け取るのはなぜですか?
コードスニペット2がスニペット1のように動作しないのはなぜですか?
//Code snippet 1
char pstr[] = "helloworld";
char *p = pstr;
p[2] = 'd';
//Code snippet 2
char *p = "helloworld";
p[2] = 'd'; //error: access violation
PS私の無知を許してください。