Practice ยท 1 of 2
Measure a Mixed Struct
The boilerplate defines:
``c
struct Record {
char kind;
long amount;
char flag;
};
`
Implement, **without naming any hard-coded sizes in the answer's logic**
(use the operators, not magic numbers):
`c
/* offset of each member, as actually compiled */
size_t rec_kind_off(void);
size_t rec_amount_off(void);
size_t rec_flag_off(void);
/* total compiled size */
size_t rec_size(void);
/* how many Records fit in a buffer of n bytes (n/sizeof, floor; 0 if n < size) */
size_t rec_capacity(size_t n);
``
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Layout Gym