是什么(* P)[8]和* P [8] C之间的区别?

编程入门 行业动态 更新时间:2024-10-23 16:27:26
本文介绍了是什么(* P)[8]和* P [8] 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之间的区别?

本文发布于:2023-08-01 04:24:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1265188.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:区别

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!