5 ms·
I particularly enjoy showing people the little known "goes to" operator: --> with example code such as this: #include <stdio.h> int main() { int
by ColinDabritz 15y ago
I particularly enjoy showing people the little known "goes to" operator:
-->
with example code such as this:
#include <stdio.h>
int main()
{
int x = 10;
while( x --> 0 ) // read "while x goes to zero"
{
printf("%d ", x);
}
}
The above code compiles and runs, listing the numbers from 9 to 0.
For more details on this little known operator, I recommend this stack overflow question:
http://stackoverflow.com/questions/1642028/what-is-the-name-of-this-operator http://stackoverflow.com/questions/1642028/what-is-the-name-...
Always a classic.
- RodgerTheGreat 15y agoReminds me of a trick from Java Puzzlers- it works exactly the same in C: #include <stdio.h> int main() { http://www.google.com printf("Hello, World!"); } (Of course, if you have syntax highlighting that label followed by a single-line comment is easier to spot.)
- palish 15y agoYou, sir, are evil! That's awesome!
- nemetroid 15y agoIt so happens that x is not continuous in 0 - the result is different if you approach 0 from the right, i.e. 0 <-- x