3 ms·
In fact, there's no way to make a C for loop run 256 times using only an 8-bit counter, because there aren't enough states. Looping N times requires N+1 evaluat
by tlb 8y ago
In fact, there's no way to make a C for loop run 256 times using only an 8-bit counter, because there aren't enough states. Looping N times requires N+1 evaluations of the termination condition, and with only 256 states of the index variable you can't have more than 255 iterations.
You can do it with a do { } while loop, which only needs N evaluations of the termination condition for N iterations.