Can we compare structures in C Programming?
-----------------------------------
Structures are generally compared by programmers element by element wise. There isn't any specific provision in C programming to compare entire structure at a time. The main reason for not being able to compare structures directly is due to padding.
What is padding in structures?
Contiguous memory allocation is done in structures. Contiguous meant adjacent memory spaces. The major deviation to contiguous memory allocation happens when the required element size of structure is less than 4 Bytes (if a 32-bit processing system is considered). To align data in memory any element size with less than 4 Bytes, is padded with extra Bytes to make reading easier from memory. Padding of these additional bytes is called structure padding.
Video on Padding in structures:
0 Comments