【发布时间】:2017-10-01 06:34:43
【问题描述】:
我希望输出是 XOllo,但我得到的是 segfault。
#include <stdio.h>
#include <string.h>
int main(){
char *buf="hello";
char *xys="XO";
while(*buf != 'l'){
*buf = *xys;
xys++;
buf++;
}
printf("%s \n", buf);
return 0;
}
o/p-: 段错误
我需要 o/p 作为 XOllo,但我遇到了 seg 错误。请建议。
Please suggest.
【问题讨论】:
-
不应修改字符串文字。
标签: c