Turn from: http://blog.csdn.net/feixiaoxing/article/details/6764791
Loops are another important technique we encounter in programming. By iterating through iterations, we can get whatever results we want. Of course, there are basic conditions for such iterations, either in terms of time, or in terms of space, or as a condition of some kind of foreign interaction. There are a number of ways to cycle, but commonly used is still: while, for, Do-while, goto these several. Many of the company's projects do not like Goto, which is not to say that Goto is not good, mainly to goto the randomness is too large, once used bad, it will reduce the readability of the code, but affect the efficiency of others.
(1) Why Do-while first executes, after judgment.
As usual, let's just look at the code example and say:
View Plain 21: int m = 10; 00401638 mov dword ptr [ebp-4],0Ah 22: do { 23: printf ("%d\n", m); 0040163f mov eax,dword ptr [ebp-4] 00401642 push eax 00401643 push offset string "%d\n" (0046f01c) 00401648 call printf (00420fb0) 0040164d add esp,8 24: m ++; 00401650 mov ecx,dword ptr [ebp-4] 00401653 add ecx,1 00401656 mov dword ptr [ebp-4],ecx 25: }while (m < 10); 00401659 cmp dword ptr [ebp-4],0Ah 0040165d jl process+1Fh (0040163f) If you replace it with a while.
View plain 21:int m = 10; 00401638 mov dword ptr [ebp-4],0ah 22:while (M <) 0040163F cmp DWORD ptr [ebp-4],14h 00401643 jge process+41h (00401661): {24:printf ("%d\n", m); 00401645 mov