I use a 64 bit linux
machine so the size of my pointers are 8 bytes, So looking at the code below , I wrote the program below to segfault right after the H
in my string(in the strcpy()
). But does not seem to happen . with the program below I thought it would overrun and corrupt the memory in x
. This below program runs fine on my system but if I add another letter in the strcpy()
it segfaults. So such a problem is obviously system dependent but how is this string not crashing the program? I did search for such a problem , if some links are present you could re direct me as well. Thanks in advance.
int main()
{
int x;
char* c ;
x = 0xF0000000;
strcpy(&c,"ABCDEFGHFFFFFF");
x++;
printf("%X\n",x);
printf("%s\n",&c);
}