0

Inside a "for-loop1", I have another "for-loop2"

For a given condition I want the "for-loop2" to terminate. So I used break. But it would terminate both for loops. I dont want to terminate the entire for loop("for-loop1"), I want to terminate the inner for loop only.

hoffnung
  • 7
  • 4
  • 3
    break will only exit the immediate loop context. You'll need to post your code in order to diagnose what's really going wrong. – NoelC Sep 01 '15 at 04:23

1 Answers1

0

Break ends only the loop you are in, not the outer loop. An alternative to break where you can be more specific where you jump to is the goto function as provided by this chap here: https://stackoverflow.com/a/22962842/4698445

Hope helps

Community
  • 1
  • 1
  • 3
    Doesn't this attempt at answer tell the original poster how to do just what he's trying not to do? – NoelC Sep 01 '15 at 04:47