Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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 */
@stanzheng

This comment has been minimized.

Copy link
Owner Author

@stanzheng stanzheng 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