在本节中,我们将展示一个带有编号步骤的图表。如果您按照步骤进行,从一个开始并遵循引导箭头,任意复杂性的C声明可以快速翻译为英语(也可以是任意复杂性)。我们将通过忽略图中的typedef来简化声明。若要读取typedef,请忽略“typedef”一词来翻译声明。如果它转换为“p is a…”,那么现在只要您想声明它所转换的类型,就可以使用名称“p”。

In this section we present a diagram with numbered steps. If you proceed in steps,starting at one and following the guide arrows, a C declaration of arbitrary complexity can quickly be translated into English (also of arbitrary complexity). We'll simplify declarations by ignoring typedefs in the diagram. To read a typedef, translate the declaration ignoring the word "typedef". If it translates to "p is a…", you can now use the name "p" whenever you want to declare something of the type to which it translates.

用于C声明的魔术解码器环(Magic Decoder Ring for C Declarations)

C中的声明以粗体字阅读,即从右到左和从左到右交替阅读。谁会想到会有一个特殊的词来形容呢!从左边读取时找到的第一个标识符开始。当我们将声明中的一个令牌与图匹配时,我们将其从进一步考虑中删除。在每一点上,我们首先看右边的令牌,然后看左边的令牌。当一切都被清除后,工作就完成了。

Declarations in C are read boustrophedonically,i.e. alternating right-to-left with left-to right. And who'd have thought there would be a special word to describe that! Start at the first identifier you find when reading from the left. When we match a token in our declaration against the diagram, we erase it from further consideration. At each point we look first at the token to the right, then to the left. When everything has been erased, the job is done.

让我们尝试几个使用图表解读声明的例子。假设我们想知道我们的第一个代码示例意味着什么:

Let's try a couple of examples of unscrambling a declaration using the diagram. Say we want to figure out what our first example of code means:

char* const *(*next)();

在我们解读这份宣言时,我们逐渐“清除”我们已经处理过的部分,以便我们能确切地看到还有多少。同样,记住const的意思是“只读”。仅仅因为它表示常量,它并不一定意味着常量。

As we unscramble this declaration, we gradually "white out" the pieces of it that we have already dealt with, so that we can see exactly how much remains. Again, remember const means "read-only". Just because it says constant, it doesn't necessarily mean constant.

该过程在表中表示。在每个步骤中,我们要处理的声明部分都用粗体打印。从第一步开始,我们将继续执行这些步骤。

The process is represented in Table. In each step, the portion of the declaration we are dealing with is printed in bold type. Starting at step one, we will proceed through these steps.

解读C声明的步骤(Steps in Unscrambling a C Declaration)

Steps in Unscrambling a C Declaration
Declaration Remaining
(start at leftmost identifier)
Next Step to Apply Result
char * const *(*next )(); step 1 say "next is a…"
char * const *(*) (); step 2,3 doesn't match, go to next step, say "next is a…"
char * const *(* )(); step 4  doesn't match, go to next step
char * const *(* )(); step 5 asterisk matches, say "pointer to …", go to step 4
char * const *() (); step 4 "(" matches up to ")", go to step 2
char * const * () ; step 2 doesn't match, go to next step
char * const * () ; step 3 say "function returning…"
char * const * ; step 4 doesn't match, go to next step
char * const * ; step 5 say "pointer to…"
char * const ; step 5 say "read-only…"
char * ; step 5 say "pointer to…"
char ; step 6 say "char"

然后把它们放在一起阅读:

“下一个是指向返回指向只读指针char的函数的指针”,我们已经完成了。现在让我们尝试一个更复杂的例子。

Then put it all together to read:
"next is a pointer to a function returning a pointer to a read-only pointer-to-char" and we're done. Now let's try a more complicated example.

char *(*c[10])(int **p);

尝试按照与上一个示例相同的方式完成这些步骤。本章末尾给出了一些步骤,让您有机会自己尝试并比较您的答案。

Try working through the steps in the same way as the last example. The steps are given at the end of this chapter, to give you a chance to try it for yourself and compare your answer.

[C指针] 用图表解读C声明:Unscrambling C Declarations by Diagram相关推荐

  1. 扩增子图表解读7三元图:三组差异数量和关系

    点击上方蓝色「宏基因组」关注我们!专业干货每日推送! 背景介绍(Introduction) 宏基因组学 宏基因组学目前的主要研究方法包括:16S/ITS/18S扩增子.宏基因组.宏转录组和代谢组,其中 ...

  2. 扩增子图表解读5火山图:差异OTU数量及变化规律

    欢迎点击「宏基因组」关注我们!专业干货每日推送! 背景介绍(Introduction) 宏基因组学 宏基因组学目前的主要研究方法包括:微生物培养组学.16S/ITS/18S扩增子.宏基因组.宏转录组. ...

  3. 扩增子三部曲:1分析图表解读大全(箱线,散点,热,曼哈顿,火山,韦恩,三元,网络)...

    点击上方蓝色「宏基因组」关注我们!专业干货每日推送! 写在前面 (Introduction) 很多刚接触高通量测序数据分析文章的学生,感觉图表丰富多样高大上,但根本看不懂,更谈何对文章的全面理解. 本 ...

  4. 宏基因组扩增子1图表解读-理解文章思路,零基础测序分析图表解读大全(箱线,散点,热,曼哈顿,火山,韦恩,三元,网络),老板再也不愁我的文献阅读了!

    本网内容转载自"宏基因组"公众号,更佳阅读体验.更多相关文章,欢迎点我跳转至公众号. 写在前面 (Introduction) 很多刚接触高通量测序数据分析文章的学生,感觉图表丰富多 ...

  5. origin三元相图_扩增子图表解读7三元图:三组差异数量和关系

    点击上方蓝色「宏基因组」关注我们!专业干货每日推送! 背景介绍(Introduction) 宏基因组学 宏基因组学目前的主要研究方法包括:16S/ITS/18S扩增子.宏基因组.宏转录组和代谢组,其中 ...

  6. 扩增子图表解读4曼哈顿图:差异OTU或Taxonomy

    点击上方蓝色「宏基因组」关注我们!专业干货每日推送! 背景介绍(Introduction) 宏基因组学 宏基因组学目前的主要研究方法包括:16S/ITS/18S扩增子.宏基因组.宏转录组和代谢组,其中 ...

  7. 比较两组数据的差异用什么图更直观_扩增子图表解读7三元图:三组差异数量和关系...

    点击上方蓝色「宏基因组」关注我们!专业干货每日推送! 背景介绍(Introduction) 宏基因组学 宏基因组学目前的主要研究方法包括:16S/ITS/18S扩增子.宏基因组.宏转录组和代谢组,其中 ...

  8. Science组合图表解读

    作者 陈威,水利部中国科学院水工程生态研究所,藻类生态学方向,R语言爱好者. 关于此图的讨论已经有一段时间了.我发现一个事实,对此图教程表现出强烈渴望的小伙伴名字后面都有"生态"二 ...

  9. 扩增子图表解读8网络图:节点OTU或类Venn比较

    作者: 刘永鑫 日期:2017-7-1 阅读时长:10min 背景介绍(Introduction) 宏基因组学 宏基因组学目前的主要研究方法包括:16S/ITS/18S扩增子.宏基因组.宏转录组和代谢 ...

最新文章

  1. 好看的按钮组件_一个能决定命运的按钮,你敢来挑战吗?
  2. PXE 网络化安装linux系统
  3. Struts2中Action的属性接收参数
  4. [转]没有找到 MFC42D.DLL,因此这个应用程序未能启动。重新安装应用程序可能会修复此问题。解决方法!...
  5. 重做《机房收费系统》——概要设计(UI)
  6. 我的实战经验:八年招聘用人心得
  7. java 标题栏_如何更改java应用程序标题栏默认图标
  8. 矩阵论作业4,5,6讲
  9. php一句话跨域,php跨域怎么解决
  10. CAD如何快速计算面积并标注?CAD计算面积并标注
  11. OAuth认证实现机制及单点登录原理
  12. Iredmail搭建
  13. 流量魔盒FlowBox 发行的代币是DMC骗局分析
  14. 推荐一个直接用于项目开发的PID库!很好用,很稳定
  15. CVPR2020——D3VO论文阅读
  16. oracle 脚本检查点,oracle nca脚本检查点
  17. HDS VSP/VM高端存储更换电池
  18. 【cocos精品】《梦幻西游》全面制霸苹果榜单 四榜登顶
  19. C/C++程序员的编程修养
  20. switch好玩吗_Switch游戏没那么少!我今天就推荐几个好玩的

热门文章

  1. Docker启动失败提示【exec user process caused: exec format error】
  2. es6中class类的全方面理解
  3. leetcode题解3-无重复字符的最长子串
  4. GlobalAuthenticationConfigurerAdapter.class 整合activiti 报错
  5. 结对-贪吃蛇-最终程序
  6. HDU 2814 斐波那契循环节 欧拉降幂
  7. 第三方插件渗透攻击之KingView
  8. MySQL带参数的存储过程小例子
  9. 连上Internet-linux鸟哥的私房菜服务器篇04(阅读笔记)
  10. python在编程序网站_Python的用户登录接口编制以及实现流程图