83. Structures-ii

Question.5

A developer casts a received UART byte buffer to a struct pointer:

typedef struct {
   uint8_t  start;
 uint32_t data;
   uint8_t  crc;
} Packet;

uint8_t rx_buf[6] = {0xA5, 0x01, 0x34, 0x12, 0x77, 0x5A};
Packet *pkt = (Packet *)rx_buf;
printf("%u", pkt->data);

The developer expects data to be 0x1234 (bytes 0x34 and 0x12 at indices 2–3). Will the output match?

Need Help? Refer to the Quick Guide below

Select Answer

Restart quiz!