Breaking out of nested loops in C++ -
Breaking out of nested loops in C++ -
this question has reply here:
can utilize break exit multiple nested loops? 14 answerssay have next code , when break want break out of inner , outer loop instead of inner loop , go straight blablabla. how can in c++?
for (int = 0; < m; i++) { (int j = 0; j < n; j++) { if (some condition) { // , break... break; // breaks out of inner loop } } } blablabla ...
"go straight [...]" sound perfect job goto
. , !
for (int = 0; < m; i++) { (int j = 0; j < n; j++) { if (some condition) { // , break... goto afterloop; // breaks out of both loops } } } afterloop: // more stuff
c++ for-loop
Comments
Post a Comment