问题描述
Objective-C中的&
符号是什么意思?我目前正在查看数据结构,并且我对此感到非常困惑。
What does the &
symbol mean in Objective-C? I am currently looking at data constucts and am getting really confused by it.
我已经浏览了网页,但还没有找到答案。我知道这可能是一个基本的Objective-C概念,但我无法理解它。
I have looked around the web for it but have not found an answer at all. I know this is possibly a basic Objective-C concept, but I just can't get my head around it.
例如:
int *pIntData = (int *)&incomingPacket[0];
这里输入数据包的代码是什么?
What is the code doing with incoming packet here?
推荐答案
&是一元运算符的C地址。它返回其操作数的内存地址。
& is the C address-of unary operator. It returns the memory address of its operand.
在您的示例中,它将返回incomingPacket数组的第一个元素的地址,然后将其转换为int * (指向int的指针)
In your example, it will return the address of the first element of the incomingPacket array, which is then cast to an int* (pointer to int)
这篇关于什么& Objective-C中的符号是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!