3 ms·
How do you get 0 + 2? I could imagine the post-increment happening after the sum: giving 0 + 1…
by JKCalhoun 7y ago
How do you get 0 + 2?
I could imagine the post-increment happening after the sum: giving 0 + 1…
- dahart 7y agoThat’s what I imagined, and what I get with Cygwin gcc, the result is 1. I thought that the post-increment was supposed to always only happen after the “statement”, but I was wrong. Other compilers, like gcc on Ubuntu return 2. This looks like a good explanation of why both are correct and why it’s confusing: https://stackoverflow.com/a/4445841 https://stackoverflow.com/a/4445841