这两个声明如下:
int (*p)[8];
int *p[8];
发布于 2011-06-01 21:51:44
第一个是指向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
实际上,你可以在你的头脑中使用一个clockwise/spiral rule来做这件事,但是自从我发现cdecl
以来,我就再也不用担心这个了,因为同样的原因,我不再在我的头脑中将大的任意32位数字从十进制转换为十六进制-如果我有必要的话,我可以这样做,但有了一个工具就容易多了:-)
发布于 2011-06-01 21:49:53
第一个p是指向一个8 int数组的指针。第二个p是指向int的8个指针的数组。
https://stackoverflow.com/questions/6202203
复制相似问题