PDA

View Full Version : continue in a double loop


Amads
31/10/2017, 05:15 PM
for(new i; i < 10; i++)
{
for(new g; g < 25; g++) if(vExample[g] == vArray[i]) continue;
}

I want to skip an iteration in the first loop (i), not the second one, in which continue is used (g).
Don't quite know how to achieve it...

10MIN
31/10/2017, 05:32 PM
I think you should break second loop, and then continue the first, or the simpler: (reversed loops (code dependant) )

for(new i; i < 25; i++)
{
for(new g; g < 10; g++) if(vExample[i] == vArray[g]) continue;
}

OneDay
31/10/2017, 06:35 PM
for(new i; i < 10; i++)
{
for(new g; g < 25; g++) if(vExample[g] == vArray[i]) goto continue_2;
continue_2:
}

Dayrion
31/10/2017, 07:12 PM
for(new i; i < 10; i++)
{
for(new g; g < 25; g++)
if(vExample[g] == vArray[i])
break;
}

It will stop the second loop and skip an iteration in the first loop.
If you don't want re-loop the second iteration, your code have no-sence