"Go directly to [...]" sound like a perfect job for goto
. And it is !
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
if (some condition) {
// Do something and break...
goto afterLoop; // Breaks out of both loops
}
}
}
afterLoop:
// More stuff