没啥区别,就是a+=b比a=a+b更简洁,初学者可能不适应会选择用a=a+b
经验积累中............
int a=10,b=20; a=a+b; printf("a=a+b=%d\n",a);对就下面的汇编代码
0040B778 |. C745 FC 0A000>mov dword ptr [ebp-4], 0A 0040B77F |. C745 F8 14000>mov dword ptr [ebp-8], 14 0040B786 |. 8B45 FC mov eax, dword ptr [ebp-4] 0040B789 |. 0345 F8 add eax, dword ptr [ebp-8] 0040B78C |. 8945 FC mov dword ptr [ebp-4], eax 0040B78F |. 8B4D FC mov ecx, dword ptr [ebp-4] 0040B792 |. 51 push ecx ; /<%d> 0040B793 |. 68 1C004200 push 0042001C ; |format = "a=a+b=%d",LF,"" 0040B798 |. E8 D358FFFF call printf ; \printf
int a=10,b=20; a+=b; printf("a+=b=%d\n",a);对应下面的汇编代码
0040B778 |. C745 FC 0A000>mov dword ptr [ebp-4], 0A 0040B77F |. C745 F8 14000>mov dword ptr [ebp-8], 14 0040B786 |. 8B45 FC mov eax, dword ptr [ebp-4] 0040B789 |. 0345 F8 add eax, dword ptr [ebp-8] 0040B78C |. 8945 FC mov dword ptr [ebp-4], eax 0040B78F |. 8B4D FC mov ecx, dword ptr [ebp-4] 0040B792 |. 51 push ecx ; /<%d> 0040B793 |. 68 1C004200 push 0042001C ; |format = "a+=b=%d",LF,"" 0040B798 |. E8 D358FFFF call printf ; \printf