Alignment: The .offsetof Property

Get to learn the working of the .offsetof property in this lesson.

We'll cover the following

The .offsetof property

Alignment is observed for members of user-defined types as well. There may be padding bytes between members so that the members are aligned according to their respective types. For that reason, the size of the following struct is not 6 bytes, as one might expect, but 12:

Get hands-on with 1200+ tech skills courses.