Last active
December 20, 2015 21:38
-
-
Save qwo/6199021 to your computer and use it in GitHub Desktop.
Evil Confusing Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int main(int argc, char** argv) | |
{ | |
int x = 10; | |
while ( x-->0) // x goes to 0 | |
{ | |
std::cout << x << "\n"; | |
} | |
} | |
/* output is | |
9 | |
8 | |
7 | |
6 | |
5 | |
4 | |
3 | |
2 | |
1 | |
0 | |
*/ | |
/* DEAL WITH IT */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The trick is line 5 is actually while( (x--)>0)