What’s the best way to do a reverse ‘for’ loop with an unsigned index?

How about:

for (unsigned i = n ; i-- > 0 ; )
{
  // do stuff with i
}

Leave a Comment