Click here to Skip to main content
15,892,839 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
int * p = NULL; // the size of p is:________.
// the value of p is:___ ____

double * q=NULL; // the size of q is:__________
// the value of q is:________

char * t=NULL; // the size of t is:________,
// the value of t is:_______

p = &a; // the value of p is:_____________

q = &d; // the value of q is:_____________

t = &c; // the value of c is:_____________

cout << *p << endl; // This displays ______. When accessing *p, the following ___ number of bytes are accessed

cout << *q << endl; // This displays ______. When accessing *q, the following ___ number of bytes are accessed

cout << *t << endl; // This displays ______. When accessing *t, the following ___ number of bytes are accessed

cout << "p+1=" << p+1 << endl; // How much is p differs from p+1?______

cout << "q+1=" << q+1 << endl; // How much is q differs from q+1?______

cout << "t+1=" << t+1 << endl; // How much is t differs from t+1?______

What I have tried:

This is what I did so far, I'm not sure how to do the rest. I very new to c++. Any help would be appreciated.

int * p = NULL; // the size of p is:____8____.
// the value of p is:___ 0____

double * q=NULL; // the size of q is:_____8_____
// the value of q is:____0____

char * t=NULL; // the size of t is:____8____,
// the value of t is:____0___
Posted
Updated 5-Oct-18 22:08pm

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

And it's pretty important that you know this stuff, so look at it, and think about it. But ... your existing answers are right, assuming you have a 64 bit system, as a pointer is always the same size regardless of what it is pointing at..
Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
 
Share this answer
 
Your homework is the best chance to learn about pointers. Read this pointers tutorial to learn about it.

Write some sample code to see it yourself. Use the sizeof operator and printf to print values.

Good luck.
 
Share this answer
 
Comments
codingBlonde 6-Oct-18 8:11am    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900