Why does the code below produces
09 17 13 FFFFFF88
Where I expect to see
09 13 88
Code below
struct ztest
{
uint8_t a;
uint16_t b;
};
struct ztest zt;
char * dd = (char *) &zt;
zt.a = 9;
zt.b = 5000;
for (i = 0; i < sizeof(zt); i++) {
printf("%02X ",dd[i]);
}
This is running on openwrt system ar71xx. The aim is to send the char array over a serial line (in case that's relevant).
char * dd = (char *) &zt;** -->>**unsigned char * dd = (unsigned char *) &zt;fwrite(&zt, ...)sizeof ztis probably 4. padding added an extra (unused) byte.