basics · intermediate · ~15 min
Move bytes between positions with shifts and masks.
Implement uint32_t swap_u32(uint32_t x) reversing the byte order (0x11223344 -> 0x44332211).
#include <stdint.h>
uint32_t swap_u32(uint32_t x) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.