In which order are the increment expressions on the right evaluated in the assignment statement? Is it undefined?

…衆ロ難τιáo~ 提交于 2019-12-01 13:29:18

It is not undefined behaviour.
You first increase x to 11, the print it, then increase it to 12 and print it, then increase it after evaluation, so x will be 13 and the whole expression will evaluate to 12.

This is caused due to the comma operator in C being a sequence point, which means it is guaranteed all side effects of previous evaluations will have been performed, and no side effect from subsequent evaluations have yet been performed.

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