Last active
January 3, 2016 11:09
-
-
Save oldcai/8454582 to your computer and use it in GitHub Desktop.
test put switch case in do...while loop
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
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 |
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> | |
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