A question. If several loops are nested inside each other, and in one of them, a break is suddenly executed; "breaks" only one cycle, or all?

  • Interrupts the current loop, one. - Nuklon

2 answers 2

It does not break, but stops regardless of the condition ... only the one in which the break was executed;

  • Thanks, got it. The word "breaks" I wrote in quotes, I still have a button that disappears. - RDSk

@RDSk , not that I would be an opponent of such questions, but IMHO fill 10 lines

#include <stdio.h> int main () { int i, j; for (i = 0; i < 10; i++) { for (j = 0; j < 10; j++) { if (j == 2) break; } puts("only one"); } return puts("Bye") == EOF; } 

and test the hypothesis faster than wait for an answer.

-

To exit multiple cycles, use goto LABEL;

(only neatly. It should be Uh ... "structural" goto ).