1. 程式人生 > >結構體指標,內容偏移

結構體指標,內容偏移

結構體指標,預設會以4位元組補齊?

指向的內容有偏移?

#pragma pack(1)
typedef struct LINKAGE {
    unsigned char source_device_id;
    unsigned char target_device_id;
    unsigned char source_device_type;
    unsigned char source_action;
    unsigned char target_device_type;
    unsigned char target_action;
    unsigned int  source_parameter;
    unsigned int  target_parameter;
    unsigned char status;
}LINKAGE;
#pragma pack()
在定義結構體的地方加
#pragma pack(1)
<pre name="code" class="objc">#pragma pack()
命令結構體以1位元組補齊