C ++找到指针的值和大小? [英] C++ find the values and size of the pointers?

查看:88
本文介绍了C ++找到指针的值和大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int * p = NULL; // p的大小是:________。

// p的值是:___ ____



double * q = NULL; // q的大小是:__________

// q的值是:________



char * t = NULL; // t的大小是:________,

// t的值是:_______



p =& a; // p的值是:_____________



q =& d; // q的值是:_____________



t =& c; // c的值是:_____________



cout<< * p<< ENDL; //这显示______。访问* p时,访问以下___个字节数



cout<< * q<< ENDL; //这显示______。访问* q时,访问以下___个字节数



cout<< * t<< ENDL; //这显示______。访问* t时,访问以下___个字节数



cout<< p + 1 =<< p + 1<< ENDL; // p与p + 1的差异是多少?______



cout<< q + 1 =<< q + 1<< ENDL; // q与q + 1相差多少?______



cout<< t + 1 =<< t + 1<< ENDL; // t与t + 1有多大差异?______



我尝试过:



这是我到目前为止所做的,我不知道如何做其余的事情。我对c ++很新。任何帮助,将不胜感激。



int * p = NULL; // p的大小是:____ 8____。

// p的值是:___ 0____



double * q = NULL; // q的大小是:_____ 8_____

// q的值是:____ 0____



char * t = NULL; // t的大小是:____ 8____,

// t的值是:____ 0 ___

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___

推荐答案

我们不做你的作业:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



你知道这些东西是非常重要的,所以看看它,并考虑一下。但是......你现有的答案是正确的,假设你有一个64位系统,因为无论指向什么指针,指针始终都是相同的大小。

自己尝试一下,你可能会发现它并不像你想象的那么困难!



如果您遇到特定问题,请询问相关问题,我们会尽力提供帮助。但是我们不会为你做这一切!
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!


你的家庭作业是学习指针的最佳机会。阅读指针教程以了解相关信息。



编写一些示例代码以便自己查看。使用sizeof运算符和printf打印值。



祝你好运。
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.


这篇关于C ++找到指针的值和大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆