M
martin
I want to initiate a union and and have the problem that I sometimes
need to use float and sometimes an int. The float values (u.fval) turns
up ok but not the ints (u.ival).
I tried typecating it as below but it does not seem to do the trick.
Would be happy if anyone has a solution for this problem.
struct str {
int i;
float f;
typedef union {
float fval;
int ival;
} u;
} tStruct;
tStruct structArray[] = {
{ 0, 0.0 , 3.2},
{ 0, 0.0 , (float)(int)9}
};
need to use float and sometimes an int. The float values (u.fval) turns
up ok but not the ints (u.ival).
I tried typecating it as below but it does not seem to do the trick.
Would be happy if anyone has a solution for this problem.
struct str {
int i;
float f;
typedef union {
float fval;
int ival;
} u;
} tStruct;
tStruct structArray[] = {
{ 0, 0.0 , 3.2},
{ 0, 0.0 , (float)(int)9}
};