Why no segmentation fault on strcpy? [duplicate]
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Undefined, unspecified and implementation-defined behavior This should seg fault. Why doesn't it. #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; } I am using gcc version 4.4.3 with the following command: gcc -std=c99 testString.c -o test I also tried