是什么(* P)[8]和* P [8] C之间的区别? [英] What is the difference between (*p)[8] and *p[8] in C?
问题描述
这两个声明如下:
INT(* P)[8];
为int * P [8];
首先是一个的单的指针指向8整数数组,而第二个是一个的阵列的8指针,各自为整数。
如果你只踢了 CDECL
,这是美妙的这样的事情:
PAX $ CDECL
键入'帮助'或'?求助CDECL>解释INT(* P); [8]
申报数p作为指针为int数组8CDECL>解释为int * P [8];
申报数p作为指针数组8为intCDECL>解释的char *(* FP [])(整型,浮点*);
声明FP为指针数组功能(INT,指针浮)
返回字符指针
实际上,有一个顺时针/螺旋规则你可以用它来做到这一点在你的脑袋,但我没有担心,自从我发现 CDECL
,出于同样的原因我不再转换任意大的32位数字从十进制在我的脑海诅咒任何更多的 - 我的可以,如果我有的到,但它是如此一个工具更容易: - )
The two declarations are as follows:
int (*p)[8];
int *p[8];
The first is a single pointer to an array of 8 integers, while the second is an array of 8 pointers, each to an integer.
If you just kick up cdecl
, it's wonderful for this sort of thing:
pax$ cdecl
Type `help' or `?' for help
cdecl> explain int (*p)[8];
declare p as pointer to array 8 of int
cdecl> explain int *p[8];
declare p as array 8 of pointer to int
cdecl> explain char*(*fp[])(int,float*);
declare fp as array of pointer to function (int, pointer to float)
returning pointer to char
There's actually a clockwise/spiral rule you can use to do this in your head but I haven't had to worry about that since I discovered cdecl
, for the same reason I no longer convert large arbitrary 32 bit numbers from decimal to hex in my head any more - I can if I have to but it's so much easier with a tool :-)
这篇关于是什么(* P)[8]和* P [8] C之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!