Hacker News new | ask | show | jobs
by StellarScience 21 days ago
> I really don't see what's supposedly awful about that loop

Exactly! That's precisely the problem with it.

(Hint: think about your code when size = 0.)

1 comments

It works perfectly fine for size = 0?
They meant x = 0.
Not sure if they meant that, since the “awful” was referring to the original loop that had no x, but the generic solution in that case is:

    for (size_t i = size; i—- > x;)