I've made a doubly linked structure in C, and need to know how to calculate the size of custom made structures. I understand the size of certain data types, and that pointers are 8 bytes on my machine.
However when I create this data type
struct doublylinked {
int data;
struct doublylinked *next;
struct doublylinked *prev;
};
I get that all the values inside add up to 20 bytes in total.
size of data = 4
size of next = 8
size of prev = 8
However when I print out the size of this data type it equals 24.
size of doublylinked = 24
Where are these extra 4 bytes coming from?
Thanks