可能重复:
未定义、未指定和实现定义的行为
这应该是段错误。为什么不呢。
#include <string.h>
#include <stdio.h>
char str1[] = "Sample string. Sample string. Sample string. Sample string. Sample string. ";
char str2[2];
int main ()
{
strcpy (str2,str1);
printf("%s\n", str2);
return 0;
}
我正在使用带有以下命令的 gcc 4.4.3 版:
gcc -std=c99 testString.c -o test
我还尝试将优化设置为 o (-O0)。