fork download
  1. #include <cstdio>
  2.  
  3.  
  4. void test(void) {
  5. bool foo = false;
  6.  
  7. for (int i=0;i<4;++i) {
  8. int var = 1;
  9. switch (var) {
  10. CASE1: case 1:
  11. if (foo) goto END; //same as break
  12. goto CASE2; //same as fallthrough
  13. CASE2: case 2:
  14. break;
  15. CASE3: case 3:
  16. goto CASE2; //fall *up*
  17. CASE4: case 4:
  18. return; //no break, but also no fallthrough!
  19. DEFAULT: default:
  20. continue; //similar, if you're in a loop
  21. }
  22. END:
  23. printf("Loop!\n");
  24. }
  25. }
  26.  
  27. int main(int argc, char* argv[]) {
  28. test();
  29. return 0;
  30. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
Loop!
Loop!
Loop!
Loop!