9
是否可以在C中修改char字符串?
我一直在努力处理各种与指针有关的C教程和书籍,但是我真正想知道的是,一旦创建了char指针,是否有可能更改它。 这是我尝试过的: char *a = "This is a string"; char *b = "new string"; a[2] = b[1]; // Causes a segment fault *b[2] = b[1]; // This almost seems like it would work but the compiler throws an error. 那么,有什么办法可以改变字符串中的值而不是指针地址?