C中的(* p)和* p 有什么区别?
这两个声明如下:
int (*p)[8]; int *p[8];
第一个是指向8个整数数组的单个指针,而第二个是8个指针的数组 ,每个指针都是一个整数。
如果你只是启动cdecl
,这对于这类事情是很好的:
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
实际上有一个顺时针/螺旋规则你可以用来做这个,但我不必担心,因为我发现了cdecl
,因为同样的原因我不再将大的任意32位数字从十进制转换为hex再往前 – 我可以,如果我不得不用工具那么容易:-)
第一个p是指向8 int数组的指针。 第二个p是一个由8个指向int的数组。