basics · intermediate · ~15 min

Read a big-endian uint32

Reconstruct an integer from bytes on the wire.

Challenge

Network byte order is big-endian. Implement uint32_t read_be32(const uint8_t *b) assembling a 32-bit value from 4 bytes, most-significant first.

Starter code

#include <stdint.h>

uint32_t read_be32(const uint8_t *b) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.