0
typedef union
{
    unsigned i;
    float x;
} f;

f array[12];

What do I need to do to address the union members in an array like this? If not possible, how can I do this?

Yu Hao
  • 119,891
  • 44
  • 235
  • 294

2 Answers2

1
typedef union
{
    unsigned i;
    float x;
} f;

f array[12];

now you can use by this way :

array[index].member=value;
user
  • 130
  • 9
0

For instance, to access the member x of the last union in the array, use array[0].x

printf("%f\n", array[11].x);
Yu Hao
  • 119,891
  • 44
  • 235
  • 294