[英]Pointer to pointer dereference with pre-increment operator
The following program gives output as 17,29,45; 以下程序的输出为17,29,45; I can't understand what does
**++pp;
我不明白
**++pp;
是什么**++pp;
mean. 意思。 Can anyone explain the program in detail.
任何人都可以详细解释该程序。
#include <stdio.h>
int main() {
static int a[] = {10, 22, 17, 29, 45};
static int *p[] = {a, a + 2, a + 1, a + 4, a + 3};
int **pp = p;
**++pp;
printf("%d %d %d", **pp, *pp[3], pp[0][2]);
}
In your code, **++pp;
在您的代码中,
**++pp;
is the same as * (* ( ++pp));
与
* (* ( ++pp));
. 。 It first increments the pointer, then deferences twice ( the first dereference result is of pointer type, to be elaborate ).
它首先使指针递增,然后进行两次引用 ( 第一个取消引用的结果是指针类型,要详细说明 )。
However, the value obtained by dereferencing is not used. 但是,不使用通过解引用获得的值。 If you have compiler warnings enabled, you'll get to see something like
如果启用了编译器警告,您将看到类似
warning: value computed is not used
警告:未使用计算值
You can remove the dereferencing, it's no use. 您可以删除取消引用,这是没有用的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.