64,636
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
char *getname();
void main()
{
char a[20];
cin>>a;
int i = 0;
while(a[i] != 0)
{
cout<<a[i]<<":"<<(int)a[i++]<<endl;//mark
}
system("pause");
}
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
char *getname();
void main()
{
char a[20];
cin>>a;
int i = 0;
while(a[i] != 0)
{
cout<<a[i]<<":"<<(int)a[i]<<endl;
i++;//mark
}
system("pause");
}
20: char a[20];
21: cin>>a;
004010C8 lea eax,[ebp-14h] ;ebp-14保存a的地址0x0012ff6c
004010CB push eax
004010CC mov ecx,offset cin (0042aa68) ;
004010D1 call istream::operator>> (00402740) ;"aaaaaaaaaaaaaaaa"
22: int i = 0;
004010D6 mov dword ptr [ebp-18h],0 ;0x0012ff68=0
23: while(a[i] != 0)
004010DD mov ecx,dword ptr [ebp-18h] ;cx=0
004010E0 movsx edx,byte ptr [ebp+ecx-14h] ;字符a的ASCI码值=0x61
004010E5 test edx,edx
004010E7 je main+84h (00401134)
24: {
25: cout<<a[i]<<":"<<(int)a[i++]<<endl;
004010E9 push offset @ILT+10(endl) (0040100f) ;endl函数的偏移入栈
004010EE mov eax,dword ptr [ebp-18h] ;ebp-18h=变量i
004010F1 movsx ecx,byte ptr [ebp+eax-14h] ;cx存储数组元素内容
004010F6 mov dword ptr [ebp-1Ch],ecx
004010F9 mov edx,dword ptr [ebp-1Ch] ;把数组中元素转存edx
004010FC push edx
004010FD mov eax,dword ptr [ebp-18h] ;i++
00401100 add eax,1
00401103 mov dword ptr [ebp-18h],eax
00401106 push offset string ":" (0042701c) ;偏移指针到":"
0040110B mov ecx,dword ptr [ebp-18h] ;把自增后的i值存入cx
0040110E mov dl,byte ptr [ebp+ecx-14h] ;数组中下一个元素的内容存入dl
00401112 push edx
00401113 mov ecx,offset cout (0042aa28) ;ecx保存cout函数的偏移地址
00401118 call @ILT+5(ostream::operator<<) (0040100a)
0040111D mov ecx,eax
0040111F call ostream::operator<< (004015f0)
00401124 mov ecx,eax
00401126 call ostream::operator<< (004012b0)
0040112B mov ecx,eax
0040112D call @ILT+0(ostream::operator<<) (00401005)
26: }
while(a[i] != 0)
{
cout<<a[i]<<":"<<(int)a[i++]<<endl;//mark
}
while(a[i] != 0)
{
cout<<a[i]<<":"<<endl;
cout<<(int)a[i++]<<endl;//mark
}
20: char a[20];
21: cin>>a;
004010C8 lea eax,[ebp-14h]
004010CB push eax
004010CC mov ecx,offset cin (0042aa68)
004010D1 call istream::operator>> (00402740)
22: int i = 0;
004010D6 mov dword ptr [ebp-18h],0
23: while(a[i] != 0)
004010DD mov ecx,dword ptr [ebp-18h]
004010E0 movsx edx,byte ptr [ebp+ecx-14h]
004010E5 test edx,edx
004010E7 je main+84h (00401134)
24: {
25: cout<<a[i]<<":"<<(int)a[i++]<<endl;//mark
004010E9 push offset @ILT+10(endl) (0040100f)
004010EE mov eax,dword ptr [ebp-18h]
004010F1 movsx ecx,byte ptr [ebp+eax-14h]
004010F6 mov dword ptr [ebp-1Ch],ecx
004010F9 mov edx,dword ptr [ebp-1Ch]
004010FC push edx
004010FD mov eax,dword ptr [ebp-18h]
00401100 add eax,1
00401103 mov dword ptr [ebp-18h],eax
00401106 push offset string ":" (0042701c)
0040110B mov ecx,dword ptr [ebp-18h]
0040110E mov dl,byte ptr [ebp+ecx-14h]
00401112 push edx
00401113 mov ecx,offset cout (0042aa28)
00401118 call @ILT+5(ostream::operator<<) (0040100a)
0040111D mov ecx,eax
0040111F call ostream::operator<< (004015f0)
00401124 mov ecx,eax
00401126 call ostream::operator<< (004012b0)
0040112B mov ecx,eax
0040112D call @ILT+0(ostream::operator<<) (00401005)
26: }
20: char a[20];
21: cin>>a;
004010C8 lea eax,[ebp-14h]
004010CB push eax
004010CC mov ecx,offset cin (0042aa68)
004010D1 call istream::operator>> (00402740)
22: int i = 0;
004010D6 mov dword ptr [ebp-18h],0
23: while(a[i] != 0)
004010DD mov ecx,dword ptr [ebp-18h]
004010E0 movsx edx,byte ptr [ebp+ecx-14h]
004010E5 test edx,edx
004010E7 je main+7Eh (0040112e)
24: {
25: cout<<a[i]<<":"<<(int)a[i]<<endl;
004010E9 push offset @ILT+10(endl) (0040100f)
004010EE mov eax,dword ptr [ebp-18h]
004010F1 movsx ecx,byte ptr [ebp+eax-14h]
004010F6 push ecx
004010F7 push offset string ":" (0042701c)
004010FC mov edx,dword ptr [ebp-18h]
004010FF mov al,byte ptr [ebp+edx-14h]
00401103 push eax
00401104 mov ecx,offset cout (0042aa28)
00401109 call @ILT+5(ostream::operator<<) (0040100a)
0040110E mov ecx,eax
00401110 call ostream::operator<< (004015f0)
00401115 mov ecx,eax
00401117 call ostream::operator<< (004012b0)
0040111C mov ecx,eax
0040111E call @ILT+0(ostream::operator<<) (00401005)
26: i++;
00401123 mov ecx,dword ptr [ebp-18h]
00401126 add ecx,1
00401129 mov dword ptr [ebp-18h],ecx
27: }