Offsets in a log entry structure

A logging tool declares the structure 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. Fill in the byte offset of each remaining member and the total size of the structure, as whole numbers of bytes.


C
struct log_entry {
    short  id;
    char   kind;
    int    count;
    char   flag;
    double value;
};
MemberOffset (bytes)Size (bytes)
id02
kind1
count4
flag1
value8
Whole structure0

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: