4 ms·
I still to this day, after about 30 years of exposure to C, 22 years of professional development, and many years of using C professionally, avoid the for() look
by vidarh 9y ago
I still to this day, after about 30 years of exposure to C, 22 years of professional development, and many years of using C professionally, avoid the for() look in C because I struggle to remember which position the comparison vs. increment goes. I prefer to use while() loops.
But I still remember the BASIC syntax you demonstrate above, 30+ years after I last programmed BASIC.
- DiThi 9y ago> because I struggle to remember which position the comparison vs. increment goes Tip: they're in the same order they're used: comparison is always run at the beginning of each iteration, and increment is always done at the end. for(init; cond; last) ... init; while(cond) { ... ; last;} But I also dislike it and love "for ... in" constructs.
- vidarh 9y agoTried many ways of remembering it, gave up and decided a more reliable workaround. I don't know why I find it so hard to remember. Then again I've found an even more reliably workaround by not writing much C these days.