The below code runs in an infinte loop.
‘i’ has been intialised with the value 1 and then compared with 0.
So printf() stmt should execute once but it runs infinetly.
unsigned int i = 1;
for (; i >= 0; i--) {
printf("Hello: %u\n",i);
}
please explain this behaviour.
As other answers said, it’s because it’s unsigned and all. I will tell you an elegant way to do what you want to do with an unsigned integer.
This
-->is referred to sometimes as the goes to operator. But it’s in fact just--and>. If you change the spacing, you’ll getMy2c