Hacker News new | past | comments | ask | show | jobs | submit login

If your for loop is for a 0-based language, it's wrong because it starts with 1.

If it's for a 1-based language, it's wrong because it compares with "<" and not "<=".

So, I guess that proves your point that it's error-prone. :)

In C, the idiomatic way is (as you surely know) "for(i = 0; i < n; ++i)".




typo, the second one was supposed to be 0 based... although that shows how off by 1 errors occur.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: