char (*p)[4];
与char *p[4];
的区别如何?
答案 0 :(得分:8)
char (*p)[4];
- 将p声明为char的数组4的指针。char *p[4];
- 将p声明为指向char的指针的数组4。答案 1 :(得分:4)
char (*p)[4];
:p
是指向长度为4的char
数组的指针。
char [4]
points to |
char [4] v
+------+ +------+------+------+------+
| p |------------>| | | | |
+------+ +------+------+------+------+
char char char char
p will point to a char [4] array. Array is not created.
p is intended to be assigned at address of a char [4]
char *p[4];
:p
是一个长度为4的数组,数组的每个位置都是指向char
的指针
+------+------+------+------+
p | | | | |
an array +------+------+------+------+
itself | | | |
v v v v
char* char* char* char*
p is an array and will be allocated in stack (if automatic)