look if c is unsigned char then it is 1 byte variable and can store
from 0 to 255. so after going one full cycle from 0 to 255 it goes
back to 0 and this keeps repeating.
so,
unsigned char c=255;
c++;
printf("%d",c);
this will print 0.
so the loop never ends.
hope this helps.

On Aug 4, 10:02 pm, Shoubhik <[email protected]> wrote:
> Hi,
>
> Here's a wierd situation..
>
> unsigned char c;
> for(c=0;c<=255 ; c++)
>      printf("%c",c);
>
> the above code gives an infinite loop in C !!!
>
> whereas, if i print
>
> unsigned char c=255;
> prinf("%c",c);
>
> the code works fine...
>
> Somebody , help me get a work around,
>
> Thanks and Regards,
> Shoubhik Bose.

-- 
You received this message because you are subscribed to the Google Groups 
"google-codejam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to