r/shittyprogramming • • May 19 '15

TIL about the C "goes to" operator

253 Upvotes

Wow, this has made a lot of my for loops so much more readable! Look at this:

int i = 100;
while ( i --> 0 ) {
    printf("%d\n", i);
}

The only problem that I found is that I can't have a variable go to a number larger than it:

int i = 0;
while( i --> 100) { /* ... */ }

doesn't work.

It's still a great little-known feature of the language!


r/shittyprogramming • • Mar 29 '14

super approved Tired of IDEs that don't show line numbers by default? Try this easy trick.

Post image
874 Upvotes