我想得到helloello这个结果,为什么会运行不出来呢?
#include<stdio.h>
#include<string.h>
int main()
{
char str[] = "hello";
char* pstr = str;
char* p = pstr + 1;
strcat(pstr,p);
puts(str);
return 0;
}
pstr 与 P内存重叠
参考 https://zhidao.baidu.com/question/1695485611736752548.html
strcat(pstr,p);
这里,把p连到pstr上,结果放在pstr
而你的pstr是常量,而且还越界了
运行结果就是:helloello