引用自 C11 标准:
Array subsripting (§ 6.5.2.1)
The definition of the subscript operator
[]
is thatE1[E2]
is identical to(*((E1)+(E2)))
.
我想知道为什么 E1
周围的括号是必需的(它们在 C89 标准中缺失),ie 其中表达式可以 (*( E1+(E2)))
与 (*((E1)+(E2)))
不同吗?
最佳答案
根据 http://www.open-std.org/jtc1/sc22/wg14/www/docs/n841.htm , 只是为了清楚起见才插入。这两个表达式在语法上是等价的。
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.
关于c - 关于数组下标运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12201210/