char *foo1 = (char*)malloc(8 * sizeof(foo1));
char foo2[8];
static char foo3[8];
if ((uintptr_t)fooX % sizeof(long) == 0)
printf("Zero\n");
else
printf("Non-zero\n");
- Replacing fooX by foo1 prints "Zero".
- Replacing fooX by foo2 prints "Zero".
- Replacing fooX by foo3 prints "Non-zero".
I understand the code but I don't get why I get zero or non-zero for each of the foo's, neither when I will get zero or not (since there are other ways/keywords to declare variables). Can you explain me ?
This code is partly taken from this post about memcpy()