Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
char c[]="opop"; c[2]='k';
但它应该给出一个总线错误,为什么它会起作用?
你所拥有的是一个数组,而不是一个字符串文字。这是完全有效的代码。
char *c="opop"; c[2]='k';
会导致未定义的行为,很可能会导致崩溃。
好读: char a[] = "string"; 有什么区别?和 char *p = "字符串";