C weird array syntax in multi-dimensional arrays

帅比萌擦擦* 提交于 2019-11-30 08:56:25

x[y] is defined as *(x + (y))

x[y][z] would become *(*(x + (y)) + z)

x[y[z]] would become *(x + (*(y + (z))))


x[4][3] would become *(*(x + (4)) + 3) would become *(*(x + 4) + 3)

3[x[4]] would become *(3 + (*(x + (4)))) would become *(*(x + 4) + 3)

3[4[x]] would become *(3 + (*(4 + (x)))) would become *(*(x + 4) + 3)

Which means they are all equivalent.

Yes. In each case x is an array which decays to a pointer and then has pointer arithmetic performed on it.

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