A tagged union inside a structure

A parser stores values as a tagged union, declared below, on a 64-bit Linux platform where char, short, int and double occupy 1, 2, 4 and 8 bytes and each is aligned to its own size. Give each value in bytes as a whole number: the size of union value, the offset of member v within struct tagged, and the size of struct tagged.


C
union value {
    int    i;
    double d;
    char   s[12];
};

struct tagged {
    char        kind;
    union value v;
    short       count;
};
Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Structure Types Questions: