23 lines
646 B
C
23 lines
646 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int main() {
|
|
long ar[10] = {31, 32, 33, 34, 35, 36, 37, 38, 39, 40};
|
|
long *ptr = &ar[3];
|
|
|
|
printf("%p\n", &ar[0]);
|
|
printf("%p\n", &ar[3]);
|
|
printf("%p\n", &ptr);
|
|
printf("%p\n", ptr);
|
|
printf("%li\n", ar[3]);
|
|
printf("%li\n", *ptr);
|
|
|
|
printf("sizeof(long) calculated with addresses: %li\n", ((void *)(&ar[3]) - (void *)(&ar[0])) / 3);
|
|
printf("sizeof(long) calculated with sizeof: %li\n", sizeof(long));
|
|
|
|
// Output of part a: "7D7A2AA0"
|
|
// Output of part b: "7D7A2AB8"
|
|
// Difference between the 2 hex values is 24. Part b is 3 longs after so each char is 24 / 3 = 8 bytes.
|
|
return 0;
|
|
}
|