What is the difference between the following declarations:
以下声明的区别是什么?
int* arr1[8];
int (*arr2)[8];
int *(arr3[8]);
What is the general rule for understanding more complex declarations?
理解更复杂的声明的一般规则是什么?
12 个解决方案
#1
385
int* arr[8]; // An array of int pointers.
int (*arr)[8]; // A pointer to an array of integers
The third one is same as the first.
第三个和第一个一样。
The general rule is operator precedence. It can get even much more complex as function pointers come into the picture.
一般规则是运算符的优先级。当函数指针进入图片时,它会变得更加复杂。
#2
246
Use the cdecl program, as suggested by K&R.
按照K&R的建议使用cdecl程序。
$ cdecl
Type `help' or `?' for help
cdecl> explain int* arr1[8];
declare arr1 as array 8 of pointer to int
cdecl> explain int (*arr2)[8]
declare arr2 as pointer to array 8 of int
cdecl> explain int *(arr3[8])
declare arr3 as array 8 of pointer to int
cdecl>
It works the other way too.
另一种方法也适用。
cdecl> declare x as pointer to function(void) returning pointer to float
float *(*x)(void )
#3
117
I don't know if it has an official name, but I call it the Right-Left Thingy(TM).
我不知道它是否有正式的名字,但我叫它“右撇子”(TM)。
Start at the variable, then go right, and left, and right...and so on.
从变量开始,然后往右,然后向左,然后右…等等。
int* arr1[8];
arr1 is an array of 8 pointers to integers.
arr1是一个由8个指针组成的数组。
int (*arr2)[8];
arr2 is a pointer (the parenthesis block the right-left) to an array of 8 integers.
arr2是一个指向8个整数数组的指针。
int *(arr3[8]);
arr3 is an array of 8 pointers to integers.
arr3是一个由8个指针组成的整数数组。
This should help you out with complex declarations.
这将帮助您使用复杂的声明。
#4
24
int *a[4]; // Array of 4 pointers to int
int (*a)[4]; //a is a pointer to an integer array of size 4
int (*a[8])[5]; //a is an array of pointers to integer array of size 5
#5
14
The answer for the last two can also be deducted from the golden rule in C:
最后两个问题的答案也可以从C的黄金法则中扣除:
Declaration follows use.
声明之前使用。
int (*arr2)[8];
int(* arr2)[8];
What happens if you dereference arr2? You get an array of 8 integers.
如果你取消了arr2会发生什么?你得到一个8个整数数组。
int *(arr3[8]);
int *(arr3[8]);
What happens if you take an element from arr3? You get a pointer to an integer.
如果你从arr3中取一个元素会发生什么?你得到一个指向整数的指针。
This also helps when dealing with pointers to functions. To take sigjuice's example:
这也有助于处理指向函数的指针。sigjuice的例子:
float *(*x)(void )
浮*(* x)(空白)
What happens when you dereference x? You get a function that you can call with no arguments. What happens when you call it? It will return a pointer to a float.
当你取消x的时候会发生什么?你会得到一个没有参数的函数。当你叫它的时候会发生什么?它将返回一个指向浮点数的指针。
Operator precedence is always tricky, though. However, using parentheses can actually also be confusing because declaration follows use. At least, to me, intuitively arr2 looks like an array of 8 pointers to ints, but it is actually the other way around. Just takes some getting used to. Reason enough to always add a comment to these declarations, if you ask me :)
不过,运算符的优先级总是很棘手。然而,使用圆括号实际上也会让人感到困惑,因为声明遵循使用。至少,对我来说,直观的arr2看起来像一个8个指向ints的指针,但实际上它是相反的。只是需要一些习惯。如果你问我的话,有足够的理由对这些声明添加评论。
edit: example
编辑:示例
By the way, I just stumbled across the following situation: a function that has a static matrix and that uses pointer arithmetic to see if the row pointer is out of bounds. Example:
顺便说一下,我偶然发现了以下情况:一个具有静态矩阵的函数,它使用指针算法来查看行指针是否超出了界限。例子:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NUM_ELEM(ar) (sizeof(ar) / sizeof((ar)[0]))
int *
put_off(const int newrow[2])
{
static int mymatrix[3][2];
static int (*rowp)[2] = mymatrix;
int (* const border)[] = mymatrix + NUM_ELEM(mymatrix);
memcpy(rowp, newrow, sizeof(*rowp));
rowp += 1;
if (rowp == border) {
rowp = mymatrix;
}
return *rowp;
}
int
main(int argc, char *argv[])
{
int i = 0;
int row[2] = {0, 1};
int *rout;
for (i = 0; i < 6; i++) {
row[0] = i;
row[1] += i;
rout = put_off(row);
printf("%d (%p): [%d, %d]\n", i, (void *) rout, rout[0], rout[1]);
}
return 0;
}
Output:
输出:
0 (0x804a02c): [0, 0] 1 (0x804a034): [0, 0] 2 (0x804a024): [0, 1] 3 (0x804a02c): [1, 2] 4 (0x804a034): [2, 4] 5 (0x804a024): [3, 7]
Note that the value of border never changes, so the compiler can optimize that away. This is different from what you might initially want to use: const int (*border)[3]
: that declares border as a pointer to an array of 3 integers that will not change value as long as the variable exists. However, that pointer may be pointed to any other such array at any time. We want that kind of behaviour for the argument, instead (because this function does not change any of those integers). Declaration follows use.
注意,边界的值从不改变,因此编译器可以优化它。这与您最初想要使用的是不同的:const int (*border)[3]:将边界声明为一个指向3个整数数组的指针,只要变量存在,它就不会改变值。但是,这个指针可以在任何时候指向任何其他这样的数组。我们希望这个参数的行为是这样的(因为这个函数不会改变这些整数中的任何一个)。声明之前使用。
(p.s.: feel free to improve this sample!)
(附:。:请随意改进这个样品!
#6
5
typedef int (*PointerToIntArray)[];
typedef int *ArrayOfIntPointers[];
#7
2
I think we can use the simple rule ..
我想我们可以用这个简单的规则。
example int * (*ptr)()[];
start from ptr
" ptr
is a pointer to " go towards right ..its ")" now go left its a "(" come out go right "()" so " to a function which takes no arguments " go left "and returns a pointer " go right "to an array" go left " of integers "
“ptr是向右转的指针。”它的")"现在go left its a "(" come out go right "()" so "to a function不带任何参数" go left ",返回一个指针" go right "到一个数组" go left "
#8
2
As a rule of thumb, right unary operators (like []
, ()
, etc) take preference over left ones. So, int *(*ptr)()[];
would be a pointer that points to a function that returns an array of pointers to int (get the right operators as soon as you can as you get out of the parenthesis)
作为经验法则,正确的一元运算符(如[],()等)优先于左边的运算符。所以,int *(* ptr)()[];将指针指向一个函数,该函数返回一个指向int的指针数组(当你从括号中取出时,尽快得到正确的操作符)
#9
2
Here's how i interpret it:
下面是我的解释:
int *something[n];
note on precedence: array subscript operator ('[ ]') has higher priority than dereference operator ('*').
优先级:数组下标操作符('[]')比dereference操作符('*')具有更高的优先级。
So, here we will apply the '[ ]' before '*', making the statement equivalent to:
因此,这里我们将在'*'之前应用'[]',使该语句等价于:
int *(something[i]);
note on how a declaration makes sense:
int num
means (num) is an (int),int *ptr
orint (*ptr)
means, (value at ptr) is an (int), which makes ptr a pointer to int.注意声明是有意义的:int num是一个(int), int *ptr或int (*ptr)的意思是,(value at ptr)是一个(int),它使ptr成为一个指向int的指针。
This can be read as, (value of the (value at ith index of the something)) is an integer. So, (value at the ith index of something) is an (integer pointer), which makes the something an array of integer pointers.
这可以被理解为,(某物的第i个索引值)是一个整数。因此,(某物的第i个索引值)是一个(整型指针),它使这个东西成为一个整数指针数组。
In the second one,
在第二个,
int (*something)[n];
To make sense out of this statement, you must be familiar with this fact:
为了理解这句话,你必须熟悉这个事实:
note on pointer representation of array: somethingElse[i] is equivalent to *(somethingElse + i)
注意数组的指针表示:somethingElse[i]等同于*(somethingElse + i)
So, replacing somethingElse with (*something), we get *(*something + i), which is an integer as per declaration. So, (*something) given us an array, which makes something equivalent to (pointer to an array).
因此,用(*something)替换其他东西,我们得到*(*something + i),这是一个整数,就像每个声明一样。所以,(*某物)给我们一个数组,它使某些东西等价于(指向数组的指针)。
#10
0
I guess the second declaration is confusing to many. Here's an easy way to understand it.
我想第二次声明会让很多人感到困惑。这里有一个简单的方法来理解它。
Lets have an array of integers, i.e. int B[8]
.
我们有一个整数数组,即int B[8]。
Let's also have a variable A which points to B. Now, value at A is B, i.e. (*A) == B
. Hence A points to an array of integers. In your question, arr is similar to A.
我们也有一个变量a指向B,现在a的值是B,也就是(* a) == B,因此指向一个整数数组。在你的问题中,arr类似于A。
Similarly, in int* (*C) [8]
, C is a pointer to an array of pointers to integer.
类似地,在int* (*C)[8]中,C是指向整数数组的指针。
#11
0
These distinctions are one of the most common cause of segfaults especially for beginning C programmers. They all involve a pointer to an array.
这些区别是最常见的原因之一,特别是对于开始C程序员。它们都包含一个指向数组的指针。
Suppose int *aptr
is a pointer to an int array. Then aptr
would be the pointer itself, and *aptr
would be the dereferenced array.
假设int *aptr是指向int数组的指针。然后,aptr将是指针本身,而*aptr将是dereferenced数组。
- int *aptr[8] means the dereferenced value of aptr[8], which isn't valid and might result in segfault.
- int *aptr[8]是指aptr[8]的dereferenced值[8],这是无效的,可能导致segfault。
- int (*aptr)[8] means the eighth value of the array, which is (*aptr).
- int (*aptr)[8]表示数组的第8个值,即(*aptr)。
- int *(aptr[8]) is identical to aptr[8], the eighth member of aptr.
- int *(aptr[8])与aptr[8]相同,是aptr的第8个成员。
-
aptr
is not an array, and it does not contain its elements aptr[k]. - aptr不是一个数组,它不包含它的元素aptr[k]。
Here is an example code that demonstrates the distinction between the three. I made a function which passes a reference to an array to demonstrate.
下面是一个示例代码,演示了三者之间的区别。我做了一个函数,它通过引用一个数组来演示。
#include <stdio.h>
#define SIZE 4
int array_function_byreference(int **);
int main() {
int array[SIZE ];
/* Sample array has values equal to square of index */
for (int k = 0; k <= SIZE ; k++) {
array[k] = k*k;
}
/* We want a pure pointer */
int *array_to_ptr = array;
/* Print three different forms of array pointing */
/* Also provide a pointer to array variable for reference */
/* Pointer to array can be treated as a double pointer */
array_function_byreference(&array_to_ptr);
}
int array_function_byreference(int **aptr) {
printf("Address of pointer aptr: %p\n", aptr);
printf("Address of *aptr: %p\n", *aptr);
for (int k = 0; k <= SIZE ; k++) {
printf("Address of *aptr[%d] : %p\n", k, &( *aptr[k] ));
printf("Address of (*aptr)[%d]: %p\n", k, &( (*aptr)[k] ));
printf("Address of (*aptr[%d]): %p\n", k, &( *(aptr[k]) ));
printf("\n");
}
}
My output (on Windows) with sizeof(int) == 4 happened to be
我的输出(在Windows上)与sizeof(int) == 4正好相反。
Address of pointer aptr: 0061FF18
Address of *aptr: 0061FF1C
Address of *aptr[0] : 0061FF1C
Address of (*aptr)[0]: 0061FF1C
Address of (*aptr[0]): 0061FF1C
Address of *aptr[1] : 00000000
Address of (*aptr)[1]: 0061FF20
Address of (*aptr[1]): 00000000
Address of *aptr[2] : 00000001
Address of (*aptr)[2]: 0061FF24
Address of (*aptr[2]): 00000001
Address of *aptr[3] : 00000004
Address of (*aptr)[3]: 0061FF28
Address of (*aptr[3]): 00000004
Address of *aptr[4] : 00000009
Address of (*aptr)[4]: 0061FF2C
Address of (*aptr[4]): 00000009
To avoid segfaults, use the middle option. You gotta use brackets!
为了避免seg,请使用中间选项。你必须使用括号!
#12
-7
In pointer to an integer if pointer is incremented then it goes next integer.
在指向一个整数的指针中,如果指针是递增的,那么它就会进入下一个整数。
in array of pointer if pointer is incremented it jumps to next array
在指针数组中,如果指针被增加,它会跳到下一个数组。
#1
385
int* arr[8]; // An array of int pointers.
int (*arr)[8]; // A pointer to an array of integers
The third one is same as the first.
第三个和第一个一样。
The general rule is operator precedence. It can get even much more complex as function pointers come into the picture.
一般规则是运算符的优先级。当函数指针进入图片时,它会变得更加复杂。
#2
246
Use the cdecl program, as suggested by K&R.
按照K&R的建议使用cdecl程序。
$ cdecl
Type `help' or `?' for help
cdecl> explain int* arr1[8];
declare arr1 as array 8 of pointer to int
cdecl> explain int (*arr2)[8]
declare arr2 as pointer to array 8 of int
cdecl> explain int *(arr3[8])
declare arr3 as array 8 of pointer to int
cdecl>
It works the other way too.
另一种方法也适用。
cdecl> declare x as pointer to function(void) returning pointer to float
float *(*x)(void )
#3
117
I don't know if it has an official name, but I call it the Right-Left Thingy(TM).
我不知道它是否有正式的名字,但我叫它“右撇子”(TM)。
Start at the variable, then go right, and left, and right...and so on.
从变量开始,然后往右,然后向左,然后右…等等。
int* arr1[8];
arr1 is an array of 8 pointers to integers.
arr1是一个由8个指针组成的数组。
int (*arr2)[8];
arr2 is a pointer (the parenthesis block the right-left) to an array of 8 integers.
arr2是一个指向8个整数数组的指针。
int *(arr3[8]);
arr3 is an array of 8 pointers to integers.
arr3是一个由8个指针组成的整数数组。
This should help you out with complex declarations.
这将帮助您使用复杂的声明。
#4
24
int *a[4]; // Array of 4 pointers to int
int (*a)[4]; //a is a pointer to an integer array of size 4
int (*a[8])[5]; //a is an array of pointers to integer array of size 5
#5
14
The answer for the last two can also be deducted from the golden rule in C:
最后两个问题的答案也可以从C的黄金法则中扣除:
Declaration follows use.
声明之前使用。
int (*arr2)[8];
int(* arr2)[8];
What happens if you dereference arr2? You get an array of 8 integers.
如果你取消了arr2会发生什么?你得到一个8个整数数组。
int *(arr3[8]);
int *(arr3[8]);
What happens if you take an element from arr3? You get a pointer to an integer.
如果你从arr3中取一个元素会发生什么?你得到一个指向整数的指针。
This also helps when dealing with pointers to functions. To take sigjuice's example:
这也有助于处理指向函数的指针。sigjuice的例子:
float *(*x)(void )
浮*(* x)(空白)
What happens when you dereference x? You get a function that you can call with no arguments. What happens when you call it? It will return a pointer to a float.
当你取消x的时候会发生什么?你会得到一个没有参数的函数。当你叫它的时候会发生什么?它将返回一个指向浮点数的指针。
Operator precedence is always tricky, though. However, using parentheses can actually also be confusing because declaration follows use. At least, to me, intuitively arr2 looks like an array of 8 pointers to ints, but it is actually the other way around. Just takes some getting used to. Reason enough to always add a comment to these declarations, if you ask me :)
不过,运算符的优先级总是很棘手。然而,使用圆括号实际上也会让人感到困惑,因为声明遵循使用。至少,对我来说,直观的arr2看起来像一个8个指向ints的指针,但实际上它是相反的。只是需要一些习惯。如果你问我的话,有足够的理由对这些声明添加评论。
edit: example
编辑:示例
By the way, I just stumbled across the following situation: a function that has a static matrix and that uses pointer arithmetic to see if the row pointer is out of bounds. Example:
顺便说一下,我偶然发现了以下情况:一个具有静态矩阵的函数,它使用指针算法来查看行指针是否超出了界限。例子:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NUM_ELEM(ar) (sizeof(ar) / sizeof((ar)[0]))
int *
put_off(const int newrow[2])
{
static int mymatrix[3][2];
static int (*rowp)[2] = mymatrix;
int (* const border)[] = mymatrix + NUM_ELEM(mymatrix);
memcpy(rowp, newrow, sizeof(*rowp));
rowp += 1;
if (rowp == border) {
rowp = mymatrix;
}
return *rowp;
}
int
main(int argc, char *argv[])
{
int i = 0;
int row[2] = {0, 1};
int *rout;
for (i = 0; i < 6; i++) {
row[0] = i;
row[1] += i;
rout = put_off(row);
printf("%d (%p): [%d, %d]\n", i, (void *) rout, rout[0], rout[1]);
}
return 0;
}
Output:
输出:
0 (0x804a02c): [0, 0] 1 (0x804a034): [0, 0] 2 (0x804a024): [0, 1] 3 (0x804a02c): [1, 2] 4 (0x804a034): [2, 4] 5 (0x804a024): [3, 7]
Note that the value of border never changes, so the compiler can optimize that away. This is different from what you might initially want to use: const int (*border)[3]
: that declares border as a pointer to an array of 3 integers that will not change value as long as the variable exists. However, that pointer may be pointed to any other such array at any time. We want that kind of behaviour for the argument, instead (because this function does not change any of those integers). Declaration follows use.
注意,边界的值从不改变,因此编译器可以优化它。这与您最初想要使用的是不同的:const int (*border)[3]:将边界声明为一个指向3个整数数组的指针,只要变量存在,它就不会改变值。但是,这个指针可以在任何时候指向任何其他这样的数组。我们希望这个参数的行为是这样的(因为这个函数不会改变这些整数中的任何一个)。声明之前使用。
(p.s.: feel free to improve this sample!)
(附:。:请随意改进这个样品!
#6
5
typedef int (*PointerToIntArray)[];
typedef int *ArrayOfIntPointers[];
#7
2
I think we can use the simple rule ..
我想我们可以用这个简单的规则。
example int * (*ptr)()[];
start from ptr
" ptr
is a pointer to " go towards right ..its ")" now go left its a "(" come out go right "()" so " to a function which takes no arguments " go left "and returns a pointer " go right "to an array" go left " of integers "
“ptr是向右转的指针。”它的")"现在go left its a "(" come out go right "()" so "to a function不带任何参数" go left ",返回一个指针" go right "到一个数组" go left "
#8
2
As a rule of thumb, right unary operators (like []
, ()
, etc) take preference over left ones. So, int *(*ptr)()[];
would be a pointer that points to a function that returns an array of pointers to int (get the right operators as soon as you can as you get out of the parenthesis)
作为经验法则,正确的一元运算符(如[],()等)优先于左边的运算符。所以,int *(* ptr)()[];将指针指向一个函数,该函数返回一个指向int的指针数组(当你从括号中取出时,尽快得到正确的操作符)
#9
2
Here's how i interpret it:
下面是我的解释:
int *something[n];
note on precedence: array subscript operator ('[ ]') has higher priority than dereference operator ('*').
优先级:数组下标操作符('[]')比dereference操作符('*')具有更高的优先级。
So, here we will apply the '[ ]' before '*', making the statement equivalent to:
因此,这里我们将在'*'之前应用'[]',使该语句等价于:
int *(something[i]);
note on how a declaration makes sense:
int num
means (num) is an (int),int *ptr
orint (*ptr)
means, (value at ptr) is an (int), which makes ptr a pointer to int.注意声明是有意义的:int num是一个(int), int *ptr或int (*ptr)的意思是,(value at ptr)是一个(int),它使ptr成为一个指向int的指针。
This can be read as, (value of the (value at ith index of the something)) is an integer. So, (value at the ith index of something) is an (integer pointer), which makes the something an array of integer pointers.
这可以被理解为,(某物的第i个索引值)是一个整数。因此,(某物的第i个索引值)是一个(整型指针),它使这个东西成为一个整数指针数组。
In the second one,
在第二个,
int (*something)[n];
To make sense out of this statement, you must be familiar with this fact:
为了理解这句话,你必须熟悉这个事实:
note on pointer representation of array: somethingElse[i] is equivalent to *(somethingElse + i)
注意数组的指针表示:somethingElse[i]等同于*(somethingElse + i)
So, replacing somethingElse with (*something), we get *(*something + i), which is an integer as per declaration. So, (*something) given us an array, which makes something equivalent to (pointer to an array).
因此,用(*something)替换其他东西,我们得到*(*something + i),这是一个整数,就像每个声明一样。所以,(*某物)给我们一个数组,它使某些东西等价于(指向数组的指针)。
#10
0
I guess the second declaration is confusing to many. Here's an easy way to understand it.
我想第二次声明会让很多人感到困惑。这里有一个简单的方法来理解它。
Lets have an array of integers, i.e. int B[8]
.
我们有一个整数数组,即int B[8]。
Let's also have a variable A which points to B. Now, value at A is B, i.e. (*A) == B
. Hence A points to an array of integers. In your question, arr is similar to A.
我们也有一个变量a指向B,现在a的值是B,也就是(* a) == B,因此指向一个整数数组。在你的问题中,arr类似于A。
Similarly, in int* (*C) [8]
, C is a pointer to an array of pointers to integer.
类似地,在int* (*C)[8]中,C是指向整数数组的指针。
#11
0
These distinctions are one of the most common cause of segfaults especially for beginning C programmers. They all involve a pointer to an array.
这些区别是最常见的原因之一,特别是对于开始C程序员。它们都包含一个指向数组的指针。
Suppose int *aptr
is a pointer to an int array. Then aptr
would be the pointer itself, and *aptr
would be the dereferenced array.
假设int *aptr是指向int数组的指针。然后,aptr将是指针本身,而*aptr将是dereferenced数组。
- int *aptr[8] means the dereferenced value of aptr[8], which isn't valid and might result in segfault.
- int *aptr[8]是指aptr[8]的dereferenced值[8],这是无效的,可能导致segfault。
- int (*aptr)[8] means the eighth value of the array, which is (*aptr).
- int (*aptr)[8]表示数组的第8个值,即(*aptr)。
- int *(aptr[8]) is identical to aptr[8], the eighth member of aptr.
- int *(aptr[8])与aptr[8]相同,是aptr的第8个成员。
-
aptr
is not an array, and it does not contain its elements aptr[k]. - aptr不是一个数组,它不包含它的元素aptr[k]。
Here is an example code that demonstrates the distinction between the three. I made a function which passes a reference to an array to demonstrate.
下面是一个示例代码,演示了三者之间的区别。我做了一个函数,它通过引用一个数组来演示。
#include <stdio.h>
#define SIZE 4
int array_function_byreference(int **);
int main() {
int array[SIZE ];
/* Sample array has values equal to square of index */
for (int k = 0; k <= SIZE ; k++) {
array[k] = k*k;
}
/* We want a pure pointer */
int *array_to_ptr = array;
/* Print three different forms of array pointing */
/* Also provide a pointer to array variable for reference */
/* Pointer to array can be treated as a double pointer */
array_function_byreference(&array_to_ptr);
}
int array_function_byreference(int **aptr) {
printf("Address of pointer aptr: %p\n", aptr);
printf("Address of *aptr: %p\n", *aptr);
for (int k = 0; k <= SIZE ; k++) {
printf("Address of *aptr[%d] : %p\n", k, &( *aptr[k] ));
printf("Address of (*aptr)[%d]: %p\n", k, &( (*aptr)[k] ));
printf("Address of (*aptr[%d]): %p\n", k, &( *(aptr[k]) ));
printf("\n");
}
}
My output (on Windows) with sizeof(int) == 4 happened to be
我的输出(在Windows上)与sizeof(int) == 4正好相反。
Address of pointer aptr: 0061FF18
Address of *aptr: 0061FF1C
Address of *aptr[0] : 0061FF1C
Address of (*aptr)[0]: 0061FF1C
Address of (*aptr[0]): 0061FF1C
Address of *aptr[1] : 00000000
Address of (*aptr)[1]: 0061FF20
Address of (*aptr[1]): 00000000
Address of *aptr[2] : 00000001
Address of (*aptr)[2]: 0061FF24
Address of (*aptr[2]): 00000001
Address of *aptr[3] : 00000004
Address of (*aptr)[3]: 0061FF28
Address of (*aptr[3]): 00000004
Address of *aptr[4] : 00000009
Address of (*aptr)[4]: 0061FF2C
Address of (*aptr[4]): 00000009
To avoid segfaults, use the middle option. You gotta use brackets!
为了避免seg,请使用中间选项。你必须使用括号!
#12
-7
In pointer to an integer if pointer is incremented then it goes next integer.
在指向一个整数的指针中,如果指针是递增的,那么它就会进入下一个整数。
in array of pointer if pointer is incremented it jumps to next array
在指针数组中,如果指针被增加,它会跳到下一个数组。