0
我試圖使用以下結構指針訪問雙指針來構造
typedef struct address {
unsigned char *mac_destn_addr;
unsigned char *mac_src_addrl
}address_t;
typedef struct frame {
address_t *eth_addr;
unsigned char *payload;
unsigned int *crc32;
}frame_t;
typedef struct eth_ctrl {
unsigned char *no_of_pkt;
unsigned short *delay;
frame_t **eth_frame;
}eth_ctrl_t;
address_t *adr;
frame_t *frame;
eth_ctrl_t *control;
void main(int argc, char *argv[])
{
adr = malloc(sizeof(address_t));
frame = malloc(sizeof(frame_t));
control = malloc(sizeof(eth_ctrl_t));
frame->eth_addr = adr;
control->eth_frame = &frame;
printf("CRC32 : 0x%x\n", (*control)->eth_frame->crc32);
}
它打印crc32
變量的地址幀的數據分組。我需要打印出現在該地址的值。 我試過*(*control)->eth_frame->crc32
,**(control->eth_frame->crc32)
它沒有打印正確的值。