typedef struct stack{
int size;
int array[30];
}STACK;
int p;
STACK *W;
(*W).array
和 (*W).array[0]
有什么区别?
如果我有 W
和 p
,如何获得指向数组中第一个元素的 int 指针?
最佳答案
What is the difference between (*W).array and (*W).array[0]
W->array
是一个数组,W->array[0]
是一个元素。
How do I get an int pointer to the first element in the array if I have W and p?
不知道要用 p
做什么,但是 W->array
已经衰减为指向第一个元素的指针。但是,如果您想要第五个元素:
int *p = &W->array[4];
关于c - 指向 C 中结构的指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9342854/