sizeof with a structural type works like any other type: the result of the statement is the size of the type in bytes. The size of the structure type is the same as the size of the object of this structure type.
The sizeof structure object may be larger than the size of the various elements of the structure types due to filling.
There may be a padding of an unspecified number of bytes after each structure element, and padding is taken into account in the size of the structure type (or object of the structure type).
To print the size of the structure type, use the z transform specifier in the printf format printf :
printf("%zu\n", sizeof (struct my_structure_type));
source share