zoukankan      html  css  js  c++  java
  • 003 初始化空间: 字符和字符串

    /*
    目录:
       一 字符和字符串初始化空间
    */
    一 字符和字符串初始化

    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";    ; 数据复制: 静态存储区 - 栈区
    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-18h],dx  
        char *pStr = "pStr123456";    ; 获取地址: 栈区指针 - 静态区字符串 
    00044DC8  mov         dword ptr [pStr],offset string "pStr123456" (046CCCh)  
        
        printf("%c", c);
    00044DCF  movsx       eax,byte ptr [c]  ; movsx : 符号扩展并传送指令
    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;
    }


    静态区字符串

    /*
    局部变量: c - 栈空间
    局部变量: str[] - 栈空间
    字符串常量: "str123456" - 静态存储区
    字符串常量: "pStr123456" - 静态存储区
    */
     
  • 相关阅读:
    协程与IO模型
    进程池与线程池
    GIL全局解释器锁
    线程编程
    进程编程
    基于UDP协议的socket
    异常处理
    jquery mobile外部js无法载入问题
    禁用或限制部分WebKit特性
    eval 返回变量值
  • 原文地址:https://www.cnblogs.com/huafan/p/11480120.html
Copyright © 2011-2022 走看看