[英]Pointer points to another pointer in structure
I have structure named temp
with member n
:我有名为
temp
的结构,成员为n
:
struct temp
{
int n;
}
I wish to declare a pointer p
to access member n
.我希望声明一个指针
p
来访问成员n
。
struct temp *p
How to access member n
by another pointer p1
which points to pointer p
.如何通过另一个指向指针
p
的指针p1
访问成员n
。
You can access member n
through a pointer to p
with您可以通过指向
p
的指针访问成员n
temp a;
temp *p = &a;
temp **p1 = &p;
(*p1)->n = 2;
p1
is a pointer to p
. p1
是指向p
的指针。 Dereferencing it gives a reference to p
.取消引用它会引用
p
。 (*p1)
and p
are equivalent. (*p1)
和p
是等价的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.