A community for students.
Here's the question you clicked on:
 0 viewing
Curry
 one year ago
How does the following pointer diagram work out in C?
Curry
 one year ago
How does the following pointer diagram work out in C?

This Question is Closed

Curry
 one year ago
Best ResponseYou've already chosen the best response.0Given the data shown above from a 16bit system, with integer x, unsigned integer y, and integer z, what will the following code snippet print out?

anonymous
 one year ago
Best ResponseYou've already chosen the best response.0int *p = &x; /* p points to the value 0x0000 at 0x0002 */ printf("%d\n", *p); /* print the value p points to (0) */ p++; /* p now points to the address 0x0004 since sizeof(int) = 2 here */ x = (int) p; /* now x's value is that address, 0x0004 */ printf("%d\n", x); /* print the value of x (0x0004) */ printf("%d\n", *p); /* p still points to the value in y at 0x0004, which is 0x0005 */ printf("%d\n", *(&(*p))); /* *p is an alias for y, so &(*p) is equivalent to p, and then *(&(*p)) gives the value in y, which is still 0x0005 */ printf("%d\n", *(p1) + 1); /* so p1 gives the address 0x0002 again, so p1 points to x, meaning *(p1) gives the value in x (0x0004) and then +1 gives 0x0005 */
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.