关于数组下标运算符 [英] About the array subscripting operator

查看:96
本文介绍了关于数组下标运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

引用C11标准:

数组替换(§6.5.2.1)

下标运算符[]的定义是E1[E2](*((E1)+(E2)))相同.

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

我想知道为什么E1周围的括号是必需的(在C89标准中缺失), ie 其中(*(E1+(E2)))的表达式可以与(*((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))) ?

推荐答案

根据 http://www.open-std.org/jtc1/sc22/wg14/www/docs/n841.htm 插入,只是为了清楚起见.这两个表达式在语法上是等效的.

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.

公开注释编号PC-UK0103
注释1.
类别:编辑更改/非规范性贡献
委员会草案小节:6.3.2.1
标题:数组下标示例
详细说明:

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:

第2款应将"(*(E1+(E2)))"替换为"(*((E1)+(E2)))",以避免 困惑.是的,我知道语法图使它非常 毫无疑问,但是第2款中的当前措词非常令人困惑.

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.

这篇关于关于数组下标运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆