This is my code
#include <stdio.h>
#include <stdint.h>
#if UINTPTR_MAX == 0xffffffff
#define SIZE 32
#elif UINTPTR_MAX == 0xffffffffffffffff
#define SIZE 64
#else
#define SIZE 69
#endif
struct Goku{
int x,y;
char b,c;
};
int main(){
printf("Word size : %d bytes\n",SIZE/8);
printf("Struct size : %lu bytes\n",sizeof(struct Goku));
printf("Integer size : %lu bytes\n",sizeof(int));
printf("Char size : %lu bytes\n",sizeof(char));
return 0;
}
This the output
Word size : 8 bytes
Struct size : 12 bytes
Integer size : 4 bytes
Char size : 1 bytes
This is what I expected
Word size : 8 bytes
Struct size : 16 bytes
Integer size : 4 bytes
Char size : 1 bytes
I expected the structure to be 16-bytes long but it turns out to be 12-bytes
What am I doing wrong here?