#include <stdio.h> #include <stdlib.h> #include <string.h> void main() { char *a = "aaaaaaaaaaaaaaaa"; char b[1]; strcpy(b, a); printf("%s\n", b); }
At startup, it prints:
aaaaaaaaaaaaaaaa
If I make * super long, for example * a = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", then this will cause segfault.
Why in the first case there is no overflow?
source share