I've always seen people writing for(int ii = 0; ii < 50; ii ++)
but for numbers < 256, why don't people write char ii
instead of int ii
since it's sure that it will be 8bits and not more?
I've always seen people writing for(int ii = 0; ii < 50; ii ++)
but for numbers < 256, why don't people write char ii
instead of int ii
since it's sure that it will be 8bits and not more?
C does all arithmetic of values smaller than int on the value converted to int, and the compiler will likely put ii into a register, so going for a smaller type won't win you anything. It might even be worse due to constantly converting back to (char).
Next, you have a problem: char is only guaranteed to go up to 127, so 255 would be out of bounds. You would have to go for unsigned char.
Not that that signifies in your example loop. For this one, there's most likely no difference after compiling.