
i thought short is 1? why did it increase by 8, from 16 to 24?
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.
This is a question of data type alignment.
The first item is always going to be at the beginning of the structure (offset 0).
The
chartakes up one byte, so the next offset would be 1. However, thedouble*is 4-byte aligned (for performance), so it goes to the next 4-byte offset, 4. On x86 (32-bit) a pointer is 4 bytes, so the next offset is 8, whereigoes.