Cái này chắc do chuỗi nên nó còn kí tự null '\0' . Cái kia đúng vì %c là character là đúng rùi. Bạn cũng thấy rõ ràng mà
.
Coi mã assembler nó sinh ra nè :
Code:
int main()
{
00411B20 push ebp
00411B21 mov ebp,esp
00411B23 sub esp,0E4h
00411B29 push ebx
00411B2A push esi
00411B2B push edi
00411B2C lea edi,[ebp-0E4h]
00411B32 mov ecx,39h
00411B37 mov eax,0CCCCCCCCh
00411B3C rep stos dword ptr [edi]
int x, y;
char op;
printf("Input two variable: ");
00411B3E push offset string "Input two variable: " (427060h)
00411B43 call @ILT+1280(_printf) (411505h)
00411B48 add esp,4
scanf("%d %d", &x, &y);
00411B4B lea eax,[y]
00411B4E push eax
00411B4F lea ecx,[x]
00411B52 push ecx
00411B53 push offset string "%d %d" (427058h)
00411B58 call @ILT+985(_scanf) (4113DEh)
00411B5D add esp,0Ch
printf("\nx=%d; y=%d", x, y);
00411B60 mov eax,dword ptr [y]
00411B63 push eax
00411B64 mov ecx,dword ptr [x]
00411B67 push ecx
00411B68 push offset string "\nx=%d; y=%d" (427048h)
00411B6D call @ILT+1280(_printf) (411505h)
00411B72 add esp,0Ch
printf("\nEnter any operator (+,-,*,/): ");
00411B75 push offset string "\nEnter any operator (+,-,*,/): " (427020h)
00411B7A call @ILT+1280(_printf) (411505h)
00411B7F add esp,4
scanf("%1s", &op);
00411B82 lea eax,[op]
00411B85 push eax
00411B86 push offset string "%1s" (42701Ch)
00411B8B call @ILT+985(_scanf) (4113DEh)
00411B90 add esp,8
printf("\nx=%d; y=%d", x, y);
00411B93 mov eax,dword ptr [y]
00411B96 push eax
00411B97 mov ecx,dword ptr [x]
00411B9A push ecx
00411B9B push offset string "\nx=%d; y=%d" (427048h)
00411BA0 call @ILT+1280(_printf) (411505h)
00411BA5 add esp,0Ch
}
Tui dùng visual 2003 ở trường nó error runtime y không xuất ra được luôn, ko rành C lắm nhưng tui đoán thì chắc là vậy T_T !