I came across something rather funny today. The "goes to" operator: -->
#include <stdio.h>
int main()
{
int x = 10;
while (x --> 0) // x goes to 0
{
printf("%d ", x);
}
}
The output is:
9 8 7 6 5 4 3 2 1 0
Anyone care to explain? ;)
That's cute but no. Anybody who's worked with C++ for any length of time will know to read this as:
No, silly, it totally works. Here:
#include <stdio.h>
int main()
{
int x = 0;
while (x --> 10) // x goes to 10, maybe, except probably not
{
printf("%d ", x);
}
}
The output is:
You could use ++< and make it work, but that just looks funny.