unsigned int i; for (i = 8 ; i >= -1; i--)
-1 converted to the largest value in the unsigned type for comparison. So for unsigned values
i >= -1
applicable only for i = UINT_MAX .
To get the given output, the easiest way is to use signed integers, for example. int
Another way is to do some magic in loop control:
for(i = 8+1; i-- > 0;)
But if you do, be sure to write a comment explaining the unusual loop control code.
source share