访问数组内容:X [N] VS N [X] [英] Accessing array contents: x[n] vs n[x]

查看:186
本文介绍了访问数组内容:X [N] VS N [X]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  <一href=\"http://stackoverflow.com/questions/5073350/accessing-arrays-by-indexarray-in-c-and-c\">Accessing在C和C ++

我最近发现,在这东西,我从来没有在C(和C ++)之前看到了访问数组可以使用的内容 X [N] N [X]

I have recently found out something that I had never seen before in C (and C++) in that for accessing the contents of an array you can use x[n] or n[x]

因此​​,例如 X [3] 相同 3 [X]

所以我的第一个问题是如何工作的,是有使用第二语法是非常有用的(除了困惑我)什么?

So my first question is how does this work and is there anything using the 2nd syntax that is useful (apart from confusing me)?

推荐答案

X [N] *(X + N)

N [X] *(N + X)

所以前pressions是等价的。有没有在使用第二有益。

so the expressions are equivalent. There is nothing beneficial in using the second.

这篇关于访问数组内容:X [N] VS N [X]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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