#include <iostream>
using namespace std;
int main()
{
unsigned char counter = 0;
for (counter = 0; counter <= 255; counter++) {
printf("%d ", counter);
}
return 0;
}
Correct Output is Infinite loop But I thought output is 0,1,...255 because unsigned char ranges from 0 to 255 .when the counter becomes 256 then only it exceeds the range. but here our condition is counter <=255 Please clear my doubt
unsigned chartype with a current value of255, the++operator will make its new value0. - Adrian Mole