zoukankan      html  css  js  c++  java
  • 关于int8_t,uint8_t.....等数据类型的理解

    实习中,今天在看公司源码的时候,发现前辈给的代码都是这样的

    typedef int8_t int8;
    typedef uint8_t uint8;
    typedef int16_t int16;
    typedef uint16_t uint16;
    typedef word_t word16;
    typedef int32_t int32;
    typedef uint32_t uint32;
    typedef dword_t dword32;
    typedef int64_t int64;
    typedef uint64_t uint64;
    typedef uint32 color_t;
    
    typedef time_t time64;
    typedef wchar_t char16;//宽字符
    typedef char    char8;
    

     身为小白的我内心是这样的      ???????

    查找后得出了结论,其实这些都是已经被typedef过的类型:

    typedef signed char int8_t;
    typedef unsigned char uint8_t;
    
    typedef int int16_t;
    typedef unsigned int uint16_t;
    
    typedef long int32_t;
    typedef unsigned long uint32_t;
    
    typedef long long int64_t;
    typedef unsigned long long uint64_t;   
    

      这些包含在inttypes.h头文件,据说这样做的原因是方便移植,比如int8就是8位大小占一字节,int32,,32位大小4字节… 
    这样相对应的占位符也就清楚了:

    char /unsigned char: %c
    int : %d 
    unsigned int: %u  
    long: %ld; 
    unsigned long:%lu
    long long: %lld(%l64d)
    unsigned long long:%Ilu(%l64u)
    

     即:

    int8_t:%c;
    uint8_t:%c;
    
    int16_t: %d;
    uint16_t:%u;
    
    int32_t:%ld;
    uint32_t:%lu;
    
    int64_t:%lld(%l64d);
    uint64_t:%llu(%l64u);

    资料:https://blog.csdn.net/eusia/article/details/76401235

  • 相关阅读:
    [ USACO 2007 FEB ] Lilypad Pond (Silver)
    [ USACO 2007 FEB ] Lilypad Pond (Gold)
    [ USACO 2007 OPEN ] Dining
    [ BZOJ 2134 ] 单选错位
    「APIO2018新家」
    「WC2018即时战略」
    「学习笔记」杜教筛
    「APIO2018选圆圈」
    「学习笔记」集合幂级数
    「NOIP2018」保卫王国
  • 原文地址:https://www.cnblogs.com/curo0119/p/8891906.html
Copyright © 2011-2022 走看看