003 Initialization space: characters and strings

 

/ * 
Directory: 
   a string of characters and space initialization 
* /

 

A character string and initialization

int main()
{
    char c = 'c';
    char str[] = "str123456";
    char *pStr = "pStr123456";
    
    printf("%c", c);
    printf("%s", pStr);
    printf("%s", str);

    return 0;
}

 

cpStr123456str123456

 

 

int main () 
{ 
    char C = ' C ' ;
 00044DA8   MOV          byte PTR [C], 63h   
    char STR [] = " str123456 " ;     ; data replication: static memory - the stack area 
00044DAC   MOV          EAX, DWORD PTR [String " str123456 " (046CC0h)]  
 00044DB1   MOV          DWORD PTR [ STR ], EAX  
 00044DB4   MOV          ECX, DWORD PTR DS: [46CC4h]  
 00044DBA   MOV          DWORD PTR [EBP-1Ch], ECX  
 00044DBD  MOV          DX, Word PTR DS: [46CC8h]  
 00044DC4   MOV          Word PTR [EBP-for 18 h], DX   
    char * pStr = " pStr123456 " ;     ; Get URL: Stack Pointer - Static string region 
00044DC8   MOV          DWORD PTR [pStr], offset String " pStr123456 " (046CCCh)   
    
    the printf ( " % C " , C) ;
 00044DCF   movsx        EAX, byte PTR [C]   ; movsx: transfer command and the sign extension 
00044DD3   Push         EAX  
 00044DD4   Push         offset String "%c" (046DB8h)  
00044DD9  call        _printf (04131Bh)  
00044DDE  add         esp,8  
    printf("%s", pStr);
00044DE1  mov         eax,dword ptr [pStr]  
00044DE4  push        eax  
00044DE5  push        offset string "%s" (046B4Ch)  
00044DEA  call        _printf (04131Bh)  
00044DEF  add         esp,8  
    printf("%s", str);
00044DF2  lea         eax,[str]  
00044DF5  push        eax  
00044DF6  push        offset string "%s" (046B4Ch)  
00044DFB  call        _printf (04131Bh)  
00044E00  add         esp,8  

    return 0;
}

 

/ * 
Local variables: c - stack space 
local variables: str [] - stack space 
string constant: "str123456" - static memory 
string constants: "pStr123456" - static memory 
* /

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/huafan/p/11480120.html