SE250:lab-2:jpar277

From Marks Wiki
Jump to navigation Jump to search

Let me just say this lab was totally annoying AND long! I started the lab totally forgetting about getting results from the linux server until a few tasks in. So I tried to go back and get results from the linux server retyping and editing code in order for it to go through the same code. Except that I had major issues with the bash shell, he really should've provided us with some basic commands ... So, my results are for the lab PCs only, I just got too frustrated with trying to find the commands for the bash shell.

Also, everytime I ran the program, the memory location addresses changed, not by much but still they changed. My guess is that its because other programs running are continuously using memory then releasing it later and according to that is where our program memory gets located.

1) The pointers to different data types are all 4 bytes.

	int *int_ip;
	long *long_ip;
	char *char_ip;
	short *short_ip;
	double *double_ip;

	printf("size of int_ip = %d\n", sizeof(int_ip));
	printf("size of long_ip = %d\n", sizeof(long_ip));
	printf("size of char_ip = %d\n", sizeof(char_ip));
	printf("size of short_ip = %d\n", sizeof(short_ip));
	printf("size of double_ip = %d\n", sizeof(double_ip));

2) The difference between (long)&x - (long)&y and (long)(&x - &y) is that one is done in hexadecimal and the other is done in normal decimal. This is the results have a difference in the muiltiple of four. E.g. 3 and 12

3) The sizeof reports back whatever we set the size of the array to be (the number in the square brakets). the value of &arr, arr+4 and &arr[4] all produced the same outcome.

varying the size of the array between int x and int y resulted in the seperation in memory of x and y

0 | 3, 12 (size of array | hexadecimal difference, decimal difference)

1 | 6, 24

2 | 6, 24

3 | 6, 24

4 | 6, 24

5 | 7, 28

6 | 7, 28

7 | 7, 28

8 | 7, 28

9 | 8, 32

10| 8, 32


4) I got pretty much the same outcomes with the globals

except for when I varied the size of the array

0 | -4, -16 (size of array | hexadecimal difference, decimal difference)

1 | -1, -4

2 | -1, -4

3 | -1, -4

4 | -1, -4

5 | -1, -4

6 | -1, -4

7 | -1, -4

8 | -1, -4

9 | -1, -4

10| -1, -4

the difference did not change, which is really weird!

5) As I stated at the start, the memory locations changed everytime I ran the program, so p1 and p2 also changed everytime. However, each and everytime, there was always a value difference of 12.

6) What is with that code?!?!?! ... so many errors @_@

7) Offsets ::::

my_char: 0

my_short: -2

my_int: -4

my_long: -8

my_float: -12

my_double: -16

8) Offsets ::::

my_char: 0

my_short: 0

my_int: 0

my_long: 0

my_float: 0

my_double: 0

9) By the time I got to this task I was already weary and it was 15 mins past the end of the lab time >.>