SE250:lab-2:hals016
Task 1
The output for Task 1 was the same (size of pointer) regardless of the different types (short,double,float,integer,long).
Lab machine
ip = 4 ip2 = 4 ip3 = 4 ip4 = 4 ip5 = 4 ip6 = 4
Even more surprising is that the Linux Server has exactly the same values as the lab machine Linux server
ip = 4 ip2 = 4 ip3 = 4 ip4 = 4 ip5 = 4 ip6 = 4
I conclude that I do not know what is going on, or why.
Task 2 + 3
In Task 2 the output varied without an obvious logical pattern.
The "(long)(&x) - (long)(&y)" resulted in 2 memory addresses that are quite close to each other.
longx longy &x = 0x22ccc4, &y = 0x22ccc0, diff = 4
The "(long)(&x - &y)" produced numbers that are quite puzzling.
long(x-y) *char0*&x = 0x22ccc4, &y = 0x22ccbc, diff = 2 *char1*&x = 0x22ccc4, &y = 0x22ccbc, diff = 2 *char2*&x = 0x22ccc4, &y = 0x22ccbc, diff = 2 *char3*&x = 0x22ccbc, &y = 0x22cc9c, diff = 8 *char4*&x = 0x22ccc4, &y = 0x22ccbc, diff = 2 *char5*&x = 0x22ccbc, &y = 0x22cc9c, diff = 8 *char6*&x = 0x22ccbc, &y = 0x22cc9c, diff = 8 *char7*&x = 0x22ccbc, &y = 0x22cc9c, diff = 8 *char8*&x = 0x22ccc4, &y = 0x22ccb4, diff = 4 *char9*&x = 0x22ccbc, &y = 0x22cc9c, diff = 8 *char10*&x = 0x22ccbc, &y = 0x22cc9c, diff = 8
Over to the linux server the output was a lot different with all the differences being the same.
long(x-y) *char0*&x = 0x22ccc4, &y = 0x22ccbc, diff = 1 *char1*&x = 0x22ccc4, &y = 0x22ccbc, diff = 1 *char2*&x = 0x22ccc4, &y = 0x22ccbc, diff = 1 *char3*&x = 0x22ccbc, &y = 0x22cc9c, diff = 1 *char4*&x = 0x22ccc4, &y = 0x22ccbc, diff = 1 *char5*&x = 0x22ccbc, &y = 0x22cc9c, diff = 1 *char6*&x = 0x22ccbc, &y = 0x22cc9c, diff = 1 *char7*&x = 0x22ccbc, &y = 0x22cc9c, diff = 1 *char8*&x = 0x22ccc4, &y = 0x22ccb4, diff = 1 *char9*&x = 0x22ccbc, &y = 0x22cc9c, diff = 1 *char10*&x = 0x22ccbc, &y = 0x22cc9c, diff = 1
In Lab2 I was presented with many errors but mostly minor ones. Some of them which the lecturer said was ok as we are only experimenting.