0
Can anyone explain the behavior of the code snippet?
#include <stdio.h> int main() { int a[] = {1, 2}; char *p; p = (char*)a; printf ("%d\n",*p); p = p + 1; printf ("%d",*p); return 0; }
3 ответов
+ 3
int require 4 bytes so a is 8 bytes in size. char requires 1 byte so you print 2 bytes of a. Change p to: int *p; and you would get both integers.
+ 1
Thanks John Wells.
0
John Wells can you please explain me about the code working