Code:
xv[0].vol = value0;
xv[0].vol = value0;
xv[0].vol = value0;
These lines are all redundant. You only need one. The same goes for your if check. There's no point in having more than one.
Aside from the xdata portion you have typed in there, sure, it's correct. This is perfectly valid, and will declare an array of unions:
Code:
union foo
{
...some stuff...
};
union foo bar[5]; /* create an array, called bar of 5 'foo' unions. */
You can compare and use union members the same way you would use struct members. If you know how to use a struct, you know how to use a union. The only difference is that all members of the same union share the same space in memory. If you change the value of one member, it affects them all.
Code:
union foo
{
char c;
int i;
double d;
float f;
};
union foo bar;
bar.c = 'a';
Now you've just modified all members of the union, since they share the same space in memory.
Quzah.