I am trying to combine and unite the sequence of bytes from an int and a short
when debugging and reading the memory it's aligned like this [FF FF FF FF 00 00 00 00]
shouldn't it looked like this [FF FF FF FF FF FF 00 00]
since i am using union?
union uniteByte{
unsigned int blockOne;
unsigned short blockTwo;
};
union uniteByte testing;
testing.blockOne =0xffffffff; //4294967295
testing.blockTwo = 0xffff; //65535
printf("%zu\n",sizeof(testing)); // size is 4 why? shouldn't it be 6?
printf("%u\n",testing.blockOne); // 4294967295
printf("%u\n",testing.blockTwo); // 65535
printf("%p",&testing); //0x7ffeefbff4e0 [FF FF FF FF 00 00 00 00]
printf("%p",&testing.blockOne); //0x7ffeefbff4e0 <-- the address is the same as in blockTwo
printf("%p",&testing.blockTwo); //0x7ffeefbff4e0 <-- the address is the same as in blockOne