Size of struct in C/ C++

In this article, we have explained how to calculate the memory size of a struct in C and C Programming Language. To find the actual size, you need to understand two concepts of padding and packing. The size is not the sum of individual elements so read on.

Table of contents:

Structure PaddingStructure Packing

Let us explore the ideas with code examples and explanation.

Structure Padding

Computer stores structure using the concept of word boundary.
The size of a word boundary is machine depe...

 •  0 comments  •  flag
Share on Twitter
Published on September 16, 2021 09:48
No comments have been added yet.