I think when you do c++ from 255, it will go to 0 and not 256 (bcoz its
unsigned char).
Hence, the condition c<=255 is always satisified and its an infinite loop

-Bharath

On 4 August 2010 10:02, Shoubhik <sbos...@gmail.com> 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 google-c...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-code+unsubscr...@googlegroups.com<google-code%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-code?hl=en.
>
>

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

Reply via email to