在下面的代码中,结果是堆栈溢出.尽管两个字符串都有空字符,但strcpy循环应该终止,因为源字符串具有空字符.为什么发生堆栈溢出?
#include <stdio.h>
#include<strings.h>
int main(void) {
char *str="Hello world";
char *str1="Good morning";
strcpy(str,str1);
printf("%s",str);
return 0;
}
Run Code Online (Sandbox Code Playgroud)