I have a For loop in C:
u8 i;
for (i=0; i <= 255; i++)
{
//code
}
Now the compiler complains that "comparison is always true due to limited range of data type" I understand that 255 is u8 max but a for loop must have a condition. What should I put there then? Thanks.
uint8_t i=0;
do {
//code
}while(++i);
what is u8
? if it means 8-bit unsigned int, then 255+1 gives zero again, so the loop starts over again. you should use larger integer type. or use do-while
as suggested in replies
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With