C Memory & Pointers Short question.

Jun 23, 2013 at 8:41pm
Hi, i have C exam tomorrow, im studing right now previous year's tests and i have problem with one question:
1
2
3
4
5
6
7
int i, *p1, x, y, z;
i = 7; 
p1 = &i; 
*p1 = 1 
x = i; 
y = (int)p1; 
z = *p1;

and the adress of i is 2 340 000.

now the answers are x=1, z=1 and y= 2293584.
I understand where x and z came from but i have no idea why y isn't simply 2 340 000.

Or maybe submited answer is wrong?
Jun 23, 2013 at 9:24pm
Did the question specify that i is stored at that address? In that case you are right that that should be the value of y. Otherwise the address will probably be different each time you run the program.
Last edited on Jun 23, 2013 at 9:24pm
Topic archived. No new replies allowed.