<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE250%3Alab-2%3Agfun006</id>
	<title>SE250:lab-2:gfun006 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE250%3Alab-2%3Agfun006"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-2:gfun006&amp;action=history"/>
	<updated>2026-04-29T16:19:11Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.kram.nz/index.php?title=SE250:lab-2:gfun006&amp;diff=4850&amp;oldid=prev</id>
		<title>Mark: 19 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-2:gfun006&amp;diff=4850&amp;oldid=prev"/>
		<updated>2008-11-03T05:18:57Z</updated>

		<summary type="html">&lt;p&gt;19 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Lab 2==&lt;br /&gt;
&lt;br /&gt;
===Question 1===&lt;br /&gt;
The size of a int pointer was 4, this was the same for all other data types in C. Originally I was confused at why there was no difference between the data types, but then I realized it&amp;#039;s just because the size of the pointer will never change. It was exactly the same on the Linux server.&lt;br /&gt;
&lt;br /&gt;
===Question 2===&lt;br /&gt;
 Address of x (&amp;amp;x) = 0012FF50&lt;br /&gt;
 Address of y (&amp;amp;y) = 0012FF54&lt;br /&gt;
 Difference of (long)(&amp;amp;x - &amp;amp;y)) = -1&lt;br /&gt;
 Difference of (long)&amp;amp;x - (long)&amp;amp;y = -4&lt;br /&gt;
&lt;br /&gt;
My results showed that the difference for (long)&amp;amp;x - (long)&amp;amp;y was -1 and the difference for (long)(&amp;amp;x - &amp;amp;y) was -4. These results changed on the Linux server to -2 and -8 respectively. The addresses were also noticeably different on the two servers. For example, the lab machine showed the address of x to be 0012FF50, while the address on Linux was 0x10010d0c. &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;DIFFICULTIES&amp;#039;&amp;#039;&amp;#039; --&amp;gt; Linux is not my friend. It took me forever until I figured out how to get onto the server and make use of it.&lt;br /&gt;
 &lt;br /&gt;
===Question 3===&lt;br /&gt;
 The size of the array is 4&lt;br /&gt;
 Address of pointer of array = 0012FF44&lt;br /&gt;
 Address of arr+4 = 0012FF48&lt;br /&gt;
 Address of &amp;amp;arr[4] = 0012FF48&lt;br /&gt;
&lt;br /&gt;
 Address of x = 0 is 0012FF50&lt;br /&gt;
 Address of y = 0 is 0012FF54&lt;br /&gt;
&lt;br /&gt;
My results show that these addresses are similar to the addresses for the above, so they are basically stored at the same place. The weird thing I found on Linux was that the address of y (which was 0x10010d14), and the address of &amp;amp;arr[4] was EXACTLY the same. Which doesn&amp;#039;t make a bit of sense...Oh well.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;DIFFICULTIES&amp;#039;&amp;#039;&amp;#039; --&amp;gt; I did not realize that when the question asked &amp;quot;What is the value of &amp;amp;arr?&amp;quot;, it meant what was the address.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;CONFUSIONS&amp;#039;&amp;#039;&amp;#039; --&amp;gt; When the size of the array was varied, there was absolutely no difference between &amp;amp;x and &amp;amp;y. I do not know whether this was suppose to happen or not. Also, I have no idea whether it was correct that when I set x = 0 and y = 0, it still made no difference where the memory was initially stored.&lt;br /&gt;
&lt;br /&gt;
===Question 4===&lt;br /&gt;
 Address of x (&amp;amp;x) = 0040DB04, Address of y (&amp;amp;y) = 0040DB00&lt;br /&gt;
 Difference of (long)(&amp;amp;x - &amp;amp;y)) = 1&lt;br /&gt;
 Difference of (long)&amp;amp;x - (long)&amp;amp;y = 4&lt;br /&gt;
 &lt;br /&gt;
 The size of the array is 4&lt;br /&gt;
 Address of pointer of array = 0040DB08&lt;br /&gt;
 Address of arr+4 = 0040DB0C&lt;br /&gt;
 Address of &amp;amp;arr[4] = 0040DB0C&lt;br /&gt;
 &lt;br /&gt;
 Address of x = 0 is 0040DB04&lt;br /&gt;
 Address of y = 0 is 0040DB00&lt;br /&gt;
&lt;br /&gt;
By changing everything to global variables, this changed where everything was stored in memory, which makes sense. &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;CONFUSIONS&amp;#039;&amp;#039;&amp;#039; --&amp;gt; Although the difference between &amp;amp;x and &amp;amp;y are still the same, they are now positive. I don&amp;#039;t quite see why...yet.&lt;br /&gt;
&lt;br /&gt;
===Question 5===&lt;br /&gt;
 Address of p1 is 0012FF30&lt;br /&gt;
 Address of p2 is 0012FF2C&lt;br /&gt;
&lt;br /&gt;
===Question 6===&lt;br /&gt;
The results were strange.&lt;br /&gt;
 &lt;br /&gt;
 sp XÆd = 0012FF40(X ↕)&lt;br /&gt;
 sp = 0012FF40(X ↕)&lt;br /&gt;
 sp XÆd = 0012FF40(X ↕)&lt;br /&gt;
 sp = 0012FF40(X ↕)&lt;br /&gt;
 sp XÆd = 0040C010(XXXXXXX)&lt;br /&gt;
 sp = 0040C010(XXXXXXX)&lt;br /&gt;
 sp XÆd = 009411F0(XXXXXXX)&lt;br /&gt;
 sp = 009411F0(XXXXXXX)&lt;br /&gt;
&lt;br /&gt;
I do not comprehend.&lt;br /&gt;
&lt;br /&gt;
From this point onwards, I had to switch computers because I ran out of time in the lab. Therefore any addresses from this point onwards will probably not make sense to the addresses above.&lt;br /&gt;
&lt;br /&gt;
===Question 7===&lt;br /&gt;
My results showed the following&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;my struct = CFC6FAAE&lt;br /&gt;
 offsets:&lt;br /&gt;
 my char: 0&lt;br /&gt;
 my short: -2&lt;br /&gt;
 my int: -4&lt;br /&gt;
 my long: -8&lt;br /&gt;
 my float: -12&lt;br /&gt;
 my double: -16&lt;br /&gt;
&lt;br /&gt;
I also noticed that the address of my structure was changing everytime I ran the code.&lt;br /&gt;
&lt;br /&gt;
===Question 8===&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;my_union = 00000000&lt;br /&gt;
 offsets:&lt;br /&gt;
 my char: 0&lt;br /&gt;
 my short: 0&lt;br /&gt;
 my int: 0&lt;br /&gt;
 my long: 0&lt;br /&gt;
 my float: 0&lt;br /&gt;
 my double: 0&lt;br /&gt;
&lt;br /&gt;
===Question 9===&lt;br /&gt;
These are the results I got:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;sp1 = 0012FF54&lt;br /&gt;
 sp1= 00921A80&lt;br /&gt;
 &amp;amp;sp2 = 0012FF50&lt;br /&gt;
 sp2 = 00921A98&lt;br /&gt;
 &lt;br /&gt;
 &amp;amp;sp3 = 0012FF4C&lt;br /&gt;
 sp3 = 00921A80&lt;br /&gt;
&lt;br /&gt;
The fact that sp1 and sp3 have the same address shows that when sp1 was freed, sp3 took up the free space.&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>