C语言和指针-回顾06-switch

 1 #include<stdio.h>
 2 
 3 void test_function(int input)
 4 {
 5     switch(input)
 6     {
 7         case 0:
 8             printf("input is 0
");
 9         case 1:
10             printf("input is 1
");
11         case 2:
12             printf("input is 2
");
13         case 3:
14             printf("input is 3
");
15         default:
16             printf("default
");
17         case 4:
18             printf("input is 4
");
19         case 5:
20             printf("input is 5
");
21             break;
22         case 6:
23             printf("input is 6
");
24             break;
25     }
26     printf("----------------------
");
27 }
28 
29 int main()
30 {
31     test_function(3);
32     test_function(7);
33 }

Output :

input is 3
default
input is 4
input is 5
----------------------
default
input is 4
input is 5
----------------------
原文地址:https://www.cnblogs.com/wuyuntana/p/14942309.html