About the array subscripting operator

别说谁变了你拦得住时间么 提交于 2019-12-22 05:37:12

问题


Quoting from the C11 standard :

Array subsripting (§ 6.5.2.1)

The definition of the subscript operator [] is that E1[E2] is identical to (*((E1)+(E2))).

I would like to know why are the brackets around E1 necessary (they were missing in the C89 standard), ie in which expression can (*(E1+(E2))) be different from (*((E1)+(E2))) ?


回答1:


According to http://www.open-std.org/jtc1/sc22/wg14/www/docs/n841.htm, it is inserted just for clarity. The two expressions are the syntatically equivalent.

Public Comment Number PC-UK0103
Comment 1.
Category: Editorial change/non-normative contribution
Committee Draft subsection: 6.3.2.1
Title: Array subscripting example
Detailed description:

Paragraph 2 should replace "(*(E1+(E2)))" by "(*((E1)+(E2)))", to avoid confusion. Yes, I know that the syntactic chart makes it quite unambiguous, but the current wording in paragraph 2 is very confusing.



来源:https://stackoverflow.com/questions/12201210/about-the-array-subscripting-operator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!