Is it possible to use the break
function to exit several nested for
loops? If so, how would you go about doing this? Can you also control how many loops the break exits?
Answer
AFAIK, C++ doesn't support naming loops, like Java and other languages do. You can use a goto, or create a flag value that you use. At the end of each loop check the flag value. If it is set to true, then you can break out of that iteration.
No comments:
Post a Comment