> for (unsigned i = n - 1; i >= 0; i--)
An defined behavior alternative:
for( size_t i = n; i --> 0; )An defined behavior alternative:
for( size_t i = n; i --> 0; )Edit: Sorry, missed the "i-- > 0" at first. The code works, but not because of changing "unsigned" to "size_t".
It makes sense to use unsigned for sizes to save a bit (or 32 bits per size). Also less invalid possible inputs to handle.