Skip to content

Instantly share code, notes, and snippets.

@oldcai
Last active January 3, 2016 11:09
Show Gist options
  • Save oldcai/8454582 to your computer and use it in GitHub Desktop.
Save oldcai/8454582 to your computer and use it in GitHub Desktop.
test put switch case in do...while loop
test case 1:
case on the top
case in do while
case in 2 loop for
case in 2 loop for
case in default
test case 2:
case in do while
case in 2 loop for
case in 2 loop for
case in default
test case 3:
case in 2 loop for
case in 2 loop for
case in default
#include<stdio.h>
void p(const char *input)
{
printf("case %s\n", input);
}
void test_case_in_loop(int n_switch)
{
int i = 0;
switch (n_switch) {
case 1:
do {
p("on the top");
case 2:
p("in do while");
} while (0);
for (i = 0; i < 2; i++) {
case 3:
p("in 2 loop for");
}
default:
p("in default");
}
}
int main(void)
{
printf("%s\n", "test case 1:");
test_case_in_loop(1);
printf("%s\n", "test case 2:");
test_case_in_loop(2);
printf("%s\n", "test case 3:");
test_case_in_loop(3);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment