Last active
February 11, 2023 01:52
-
-
Save ae-s/96ace20635afc1af4dcf to your computer and use it in GitHub Desktop.
Example of continue within a case statement, in C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(void) | |
{ | |
int i = 0; | |
while (i < 5) { | |
i++; | |
printf("\n%d\n", i); | |
switch (i) { | |
case 1: | |
puts("one"); | |
continue; | |
case 2: | |
puts("two"); | |
break; | |
default: | |
puts("default"); | |
break; | |
} | |
puts("cycling"); | |
} | |
/* | |
puts("now continue in nothing"); | |
continue; | |
puts("now break in nothing"); | |
break; | |
*/ | |
puts("done"); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ gcc switch-continue.c | |
$ ./a.out | |
1 | |
one | |
2 | |
two | |
cycling | |
3 | |
default | |
cycling | |
4 | |
default | |
cycling | |
5 | |
default | |
cycling | |
done | |
$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment