zoukankan      html  css  js  c++  java
  • 复合类型变量其首地址的几种表示方式

    > 测试代码

     1 #include "stdio.h"
     2 
     3 
     4 typedef char           int8_t;
     5 typedef short          int16_t;
     6 typedef int            int32_t;
     7 typedef long long      int64_t;
     8 
     9 typedef unsigned char           uint8_t;
    10 typedef unsigned short          uint16_t;
    11 typedef unsigned int            uint32_t;
    12 typedef unsigned long long      uint64_t;
    13 
    14 
    15 /* ′?′¢×????óê?μ?μ?TDA5238?á1?êy?Y?á11 */
    16 typedef struct
    17 {
    18     uint8_t UniqueID[4];         /* éè±??¨ò?DòáDo? */
    19     uint8_t TyrePosition;        /* ??�???�e?? */
    20     int16_t Pressure;            /* ??�??1 */
    21     int16_t Temperature;         /* ??ì¥???è */
    22     int16_t Acceleration;        /* ??á|?ó?ù?è */
    23     int16_t Voltage;             /* μ??1?μ */
    24     uint8_t CRC8;                /* D£?é?? */
    25     uint8_t RESERVED[16];        /* ±£á?×??ú */
    26 }TDA5235_RESULT_s;
    27 
    28 typedef union
    29 {
    30     TDA5235_RESULT_s tda5235_obj;
    31     uint8_t tda5235_buf[sizeof(TDA5235_RESULT_s)];
    32 }TDA5235_RESULT_u;
    33 
    34 TDA5235_RESULT_u tda5235_result;    /* ì¥?1×????á1?êy?Y?á1? */
    35 
    36 //uint8_t TDA5235_Read_FIFO(uint8_t *pObj)
    37 
    38 /* 结构体首地址的几种表示 */
    39 int main(void)
    40 { 
    41     printf("This is a struct-address example!
    ");
    42 
    43     printf("&tda5235_result: %#X
    ", &tda5235_result);
    44     printf("&tda5235_result.tda5235_obj: %#X
    ", &tda5235_result.tda5235_obj);
    45     printf("&tda5235_result.tda5235_buf: %#X
    ", &tda5235_result.tda5235_buf);
    46     printf("&tda5235_result.tda5235_obj.UniqueID: %#X
    ", &tda5235_result.tda5235_obj.UniqueID);
    47 
    48     return 0;
    49 }

    > 运行结果

  • 相关阅读:
    It is unuseful to regret
    越难熬的时候,越要靠自己
    2019/11/11
    QT Http
    QT 初步认识
    模板
    RTTI(Runtime Type Infomation)
    位域
    C++ 多字节string转UTF-8 string
    C++ 读写csv文件
  • 原文地址:https://www.cnblogs.com/skullboyer/p/8351705.html
Copyright © 2011-2022 走看看