For and While

John Love-Jensen eljay@adobe.com
Fri Feb 21 14:07:00 GMT 2003


Hi Ben,

>This is not true if you use 'continue'.

Yes, it's still true.  Here's the for-loop:

for(int i = 0; i < 100; ++i) {
    if(i % 10 == 4)
        continue;
    cout << i << endl;
}

Convert the syntactic sugar for-loop to while-loop...
{
    int i = 0;
    while(i < 100) {
        if(i % 10 == 4)
            goto step;
        cout << i << endl;
step:
        ++i;
    }
}

--Eljay



More information about the Gcc-help mailing list