"For" infinite loop

bioinfornatics bioinfornatics at fedoraproject.org
Sat Aug 11 13:00:40 PDT 2012


Le samedi 11 août 2012 à 20:48 +0200, bearophile a écrit :
> RivenTheMage:
> 
> > This is infinite loop:
> >
> > for (ubyte i=0; i<=255; i++)
> > {
> >       ...
> > }
> >
> > I guess it's a bug?
> 
> One way to scan all the ubytes with a for loop:
> 
> import std.stdio;
> void main() {
>      for (ubyte i = 0; ; i++) {
>          write(i, " ");
>          if (i == 255)
>              break;
>      }
> }
> 
> Bye,
> bearophile

n this case why not using a while loop ?



More information about the Digitalmars-d-learn mailing list