"For" infinite loop

bearophile bearophileHUGS at lycos.com
Sat Aug 11 11:48:52 PDT 2012


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


More information about the Digitalmars-d-learn mailing list