• 002 格式化输出


    /*
    目录:
       一 不同类型用其他类型输出
       二 看原理  
    */
     一 不同类型用其他类型输出

    int main()
    {
        printf("%d
    ", 'c');    // 输出方式: 字符类型 - 整数类型
        printf("%c", 99);       // 输出方式: 整数类型 - 字符类型
        
        return 0;
    }


    /*
    99
    c
    */
    二 看原理 
    int main()
    {
    00044290  push        ebp  
    00044291  mov         ebp,esp  
    00044293  sub         esp,0C0h  
    00044299  push        ebx  
    0004429A  push        esi  
    0004429B  push        edi  
    0004429C  lea         edi,[ebp-0C0h]  
    000442A2  mov         ecx,30h  
    000442A7  mov         eax,0CCCCCCCCh  
    000442AC  rep stos    dword ptr es:[edi]  
        printf("%d
    ", 'c');
    000442AE  push        63h  
    000442B0  push        offset string "%d
    " (046CC0h)  
    000442B5  call        _printf (04131Bh)  
    000442BA  add         esp,8  
        printf("%c", 99);
    000442BD  push        63h  
    000442BF  push        offset string "%c" (046B4Ch)  
    000442C4  call        _printf (04131Bh)  
    000442C9  add         esp,8  
    
        return 0;
    000442CC  xor         eax,eax  
    }
    printf("%d
    ", 'c');
    000442AE  push        63h

    原理: 编译器对字符类型提取做转换->整数类型



  • 相关阅读:
    java学习的第三天
    java学习的第二天
    java学习的第一天
    兼容性测试2
    兼容性测试
    安全性测试
    界面测试
    功能性测试
    简历小技巧
    day13
  • 原文地址:https://www.cnblogs.com/huafan/p/11479960.html
Copyright © 2020-2023  润新知