continue <label> equivalent in C/C++/C#
Java seems to have done something right in this regard; with continue <label>
, you can, for example, instruct an outer loop to continue
. Remember, continue
glues to the inner-most loop.
For example, you could do write this in Java:
outer_loop:
for (...) {
for (...) {
continue outer_loop;
}
}
To accomplish something similar in C-like languages, you could do this:
for (...) {
for (...) {
goto continue_outer_loop;
}
continue_outer_loop:
; /* no op */
}
(adapted from post)
(Yes, goto
s still have their place.)