cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
user name:
password:
Forgot your password?
please wait
try again
cancel
forgot your password?
sign up
log in
[Legacy version]
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
C Memory & Pointers Short question.
C Memory & Pointers Short question.
Jun 23, 2013 at 8:41pm
Jun 23, 2013 at 8:41pm UTC
ldv
(1)
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
Jun 23, 2013 at 9:24pm UTC
Peter87
(11251)
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
Jun 23, 2013 at 9:24pm UTC
Topic archived. No new replies allowed.