加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

关于数组下标运算符

发布时间:2020-12-16 03:43:54 所属栏目:百科 来源:网络整理
导读:引用C11标准: Array subsripting (§ 6.5.2.1) The definition of the subscript operator [] is that E1[E2] is identical to (*((E1)+(E2))) . 我想知道为什么E1周围的括号是必要的(它们在C89标准中缺失),即哪个表达式可以(*(E1(E2)))不同于(*((E1)(E2)))
引用C11标准:

Array subsripting (§ 6.5.2.1)

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

我想知道为什么E1周围的括号是必要的(它们在C89标准中缺失),即哪个表达式可以(*(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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读