IMO *always* prefer a for loop over while or do-while.
The for (i = 0; i < N; i++) is such a strong paradigm in C. You
instantly know how many times you're going to loop, at a glance. Not so
with with the alternatives, which should be used sparingly.
while () {} _is_ a paradigm, for-loop is syntax sugar on top of it.
And yes, the do-while suggested above is buggy, and you actually need to
stop and think to see why.
It depends if pixels can be 0 or not and if it's not, then does it contain last
or number.
The do {} while (--pixels); might be buggy iff pixels may be 0.
Attachment:
OpenPGP_signature
Description: OpenPGP digital signature