Code: Select all
typedef struct pokus_struct {
unsigned char unsignedchar1;//1 byte
float float1; //4 bytes
} Pokus;
Pokus pokus;
pokus.unsignedchar1=1;
pokus.float1=2;
Serial.println(sizeof(pokus)); // return to terminal 8
Serial.write((byte*)&pokus, sizeof(pokus)); // 01 00 00 00 00 00 00 40
Serial.println(sizeof(pokus.unsignedchar1)); // 1
Serial.write((byte*)&pokus.unsignedchar1, sizeof(pokus.unsignedchar1)); // 01
Serial.println(sizeof(pokus.float1)); // 4
Serial.write((byte*)&pokus.float1, sizeof(pokus.float1)); // 00 00 00 40
I also tried define struct items with uint8_t, float_t, but it was similar (8 bytes).
Why struct size is not 5 bytes? , why it is 8 bytes?
thanks