For the below program, I was expecting the sizeof(node1) and sizeof(node2) to be 12 bytes on a 64 bit platform. But it seems that sizeof(node1) = 12 and sizeof(node2) = 16. Why the difference?
#include <stdio.h>
struct node1
{
int a;
int b;
int c;
};
struct node2
{
int* a;
int c;
};
int main()
{
printf("size1 = %d, size2 = %d\n", sizeof(node1), sizeof(node2));
return 0;
}
Output
size1 = 12, size2 = 16