So I'm beginning my studies of data structures and came across this which doesn't make sense to me:
typedef struct s
{
int number;
struct s *p;
}
s;
int main()
{
s *list = NULL;
printf("%lu\n", sizeof(list->number));
printf("%lu\n", sizeof(list->p));
printf("%lu\n", sizeof(s));
}
On my system, I get the output 4, 8, 16, respectively. I don't understand this, as 4 + 8 = 12, yet the sizeof(s) is printing the value 16. Where are these 4 extra bytes inside the struct? Am I missing something?
Any help will be greatly appreciated!