204. Union

Question.3

A developer sends a float over UART as raw bytes:

union FloatConverter {
   float f;
    uint8_t b[4];
};

void send_temp(float temp) {
    FloatConverter u;
    u.f = temp;
    uart_transmit(u.b, 4);  // Send 4 bytes
}

What technique does this demonstrate?

Need Help? Refer to the Quick Guide below

Select Answer