本文介绍了这是一个指向数组开头的指针的指针吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是在帮助某人处理一些代码.他有这个:
I've just been helping someone out with some code. He had this:
char dataArray[10];
然后想得到一个指向数组开头的指针.而不是使用:
Then wanted to get a pointer to the start of the array. Rather than use:
&dataArray[0]
或者只是
dataArray
他用过
&dataArray
他最终得到了一个指向那里的指针的指针吗?我不确定 &dataArray
会给他什么.
Did he end up with a pointer to a pointer there? I'm not sure what &dataArray
would give him.
推荐答案
&dataArray[0]
是char *
类型.这是一个指向char
的指针.dataArray
是char[10]
类型&dataArray
的类型为char (*)[10]
.这是一个指向数组的指针.&dataArray[0]
is of typechar *
. That is a pointer tochar
.dataArray
is of typechar[10]
&dataArray
will be of typechar (*)[10]
. That is a pointer-to-array.
除此之外,值将是相同的,即它们指向相同的地址但它们的类型不需要兼容.
Apart from that, the value will be same, i.e., they point to the same address but their types need not be compatible.
这里没有一个是指针到指针.它们只是不同类型的指针.
None of them is a pointer-to-pointer here. They are just pointer with different types.
这篇关于这是一个指向数组开头的指针的指针吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!