QQualcomm·DSASDE-1Technical Phone Screen
Detect Endianness / Swap Byte Order
Problem
Write code to detect whether the machine is little- or big-endian, and to byte-swap a 32-bit value.
Example
0x12345678 -> 0x78563412
Constraints
- Use a union or pointer cast to inspect bytes
What Qualcomm looks for
Comfort with memory representation and pointer/union tricks.
added 6 days ago