After reading Hidden Features and Dark Corners of C++/STL on comp.lang.c++.moderated, I was completely surprised that the following snippet compiled and worked in both Visual Studio 2008 and G++ 4.4.
Here's the code:
#include <stdio.h>
int main()
{
int x = 10;
while (x --> 0) // x goes to 0
{
printf("%d ", x);
}
}
I'd assume this is C, since it works in GCC as well. Where is this defined in the standard, and where has it come from?
++or--before... – Matthew Scharley Oct 29 '09 at 7:09#define upto ++<,#define downto -->. If you're feeling evil, you can do#define for while(and#define do ) {(and#define done ;}) and writefor x downto 0 do printf("%d\n", x) doneOh, the humanity... – Chris Lutz Mar 4 '10 at 7:07