Skip to content

Instantly share code, notes, and snippets.

@qwo
Last active December 20, 2015 21:38
Show Gist options
  • Save qwo/6199021 to your computer and use it in GitHub Desktop.
Save qwo/6199021 to your computer and use it in GitHub Desktop.
Evil Confusing Gist
#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 */
@qwo
Copy link
Author

qwo commented Aug 10, 2013

The trick is line 5 is actually while( (x--)>0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment