Skip to main content

Practice ยท 5 of 6

Reorder for Size

CHALLENGE
Difficulty: advanced+25 XP

The struct ``c struct Blob { char tag; double weight; short qty; char flag; }; ` measures 24 bytes here. Implement size_t packed_size(void) returning what sizeof would be for the best reordering of the same members (largest-first). Define the reordered struct locally and return its sizeof` โ€” reasoning made executable.

Back to lesson: Practice: Object Layout Forensics