Turn from: http://blog.csdn.net/feixiaoxing/article/details/6761837#comments
In our usual programming, used to judge a lot of places, but there are three main ways: If-else;switch; :。 One of the last ways is essentially the same as if-else. Switch and If-else are actually the same, if we change the switch to if (...). {} else if (...). {} else {}, then you achieve the same effect as the switch actually, familiar friends will have this experience. Perhaps some friends still do not believe that, we can use their own to write examples of comparison to see.
(1) is the break in switch important?
View Plain 21: int m = 10; 004017A8 mov dword ptr [ebp-4],0Ah 22: switch (m) 23: { 004017af mov eax,dword ptr [ebp-4] 004017b2 mov dword ptr [ebp-8],eax 004017b5 cmp dword ptr [ebp-8],0Ah 004017b9 je process+33h (004017C3) 004017BB cmp dword ptr [ebp-8],0bh 004017bf je process+42h (004017D2) 004017c1 jmp process+4fh ( 004017DF) 24: case 10: 25: printf ("ten!\n"); 004017C3 push offset string "ten!\n" (0046f028) 004017c8 call printf (004214d0) 004017cd add esp,4 26: break; 004017D0 jmp process+4Fh (004017DF) 27 : 28: case 11: 29: printf ("eleven!\n"); 004017d2 push offset string "eleven!\n" (0046f01c) 004017d7 call printf (004214d0) 004017dc add esp,4 30: break;