
Why are the offsets: 0 4 8 16 and 24? int = 4 bytes, double = 8 bytes. Why are there x’s on the markings? How do you know when to use x’s?
How does the other 2 structs and union offsets work?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Because a data type generally aligns to its size. So a four-byte integer will usually begin on a multiple of four bytes. This is not always necessary but it’s often an efficiency method. It is necessary in some architectures in that they’ll actually crash (raise some sort of error) if you try to access misaligned data.
The reason you have the
xcharacters is because they’re the padding required to align the following data item.