#include <stdio.h>
#include <stdint.h>
union Data {
uint8_t index; // 1 byte
float resource; // 4 bytes
};
int main() {
union Data data;
data.index = 20;
printf("Index: %d\n", data.index);
data.resource = 5.0;
printf("Resource: %f, %d\n", data.resource, data.index);
printf("Index: %d\n", data.index);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRpbnQuaD4KCnVuaW9uIERhdGEgewogICAgdWludDhfdCBpbmRleDsgICAgICAgLy8gMSBieXRlCiAgICBmbG9hdCByZXNvdXJjZTsgICAgICAvLyA0IGJ5dGVzCn07CgppbnQgbWFpbigpIHsKICAgIHVuaW9uIERhdGEgZGF0YTsKCiAgICBkYXRhLmluZGV4ID0gMjA7CiAgICBwcmludGYoIkluZGV4OiAlZFxuIiwgZGF0YS5pbmRleCk7CgogICAgZGF0YS5yZXNvdXJjZSA9IDUuMDsKICAgIHByaW50ZigiUmVzb3VyY2U6ICVmLCAlZFxuIiwgZGF0YS5yZXNvdXJjZSwgIGRhdGEuaW5kZXgpOwpwcmludGYoIkluZGV4OiAlZFxuIiwgZGF0YS5pbmRleCk7CiAgICByZXR1cm4gMDsKfQo=