0

Hi guys,

I've got two loops, and I want to be able to continue; the outermost loop when the innermost loop finds something. How would I do that?

//(...)
    for (n = startStorage; n < quadcount; n++) {
        if (!notOptimized(n, optimized)) continue;
        int *x = &quadindex[n*4];
        for (eachX = 0; eachX < 4; eachX++) {
            if(facesPerVert[x[eachX]] > 4) continue n-loop, not eachX-loop!;
//(...)

TIA,
Clockowl

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Clockowl
1

break from the inner loop and then continue from the outer loop. If there's more to the body, you may need a flag or something similar:

while (condition) {
  int nextIteration = 0;

  while (condition) {
    if (condition) {
      nextIteration = 1;
      break;
    }
  }

  if (nextIteration)
    continue;

  ...
}
Votes + Comments
Simple clean example.
0

It's the only way eh? Well I unrolled the loop as it's only 4 iterations, but thanks a lot for your input. :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.