Skip to content

Instantly share code, notes, and snippets.

@ae-s
Last active February 11, 2023 01:52
Show Gist options
  • Save ae-s/96ace20635afc1af4dcf to your computer and use it in GitHub Desktop.
Save ae-s/96ace20635afc1af4dcf to your computer and use it in GitHub Desktop.
Example of continue within a case statement, in C
#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;
}
$ 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