C中多维数组变量增加错误
我很想知道 C 中多维数组的行为增加如下:
int x[10][10];
y = x[++i, ++j];
我知道这是错误的方式。我只想知道编译器在这种情况下会做什么,以及如果程序员在他的代码中这样做会产生什么后果。
I have the curiosity to know the behaviour, in C, of a multidimensional array increased as below:
int x[10][10];
y = x[++i, ++j];
I know that is the wrong way. I just want to know what the compiler do in this case and what will be the consequence if a programmer do this in his code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是逗号运算符,被误用了。
++i, ++j
产生j + 1
的值,并有 2 个副作用(修改i
和j)。整个事情基本上意味着
++i; y = x[++j]
。哪个有效或无效,取决于 y 的类型。?很可能其他程序员会给他/她投以杀气。
That is the comma operator, misused.
++i, ++j
yields the value ofj + 1
and has 2 side effects (modifyingi
andj
). The whole thing basically means++i; y = x[++j]
. Which will work or not, depending on the type ofy
.Well, most likely other programmers will give him/her murderous looks.