Is there some easy way of storing and restoring different types in one variable?
I thought about using:
typedef enum {
float_e, int_e, char_e
} types;
typedef struct {
types type;
void *data;
} array_t;
Or this:
typedef enum {
float_e, int_e, char_e
} types;
typedef struct {
types type;
union {
float f;
int i;
char c;
}
} array_t;
And then I'd like to use the data in many different functions, but I don't want to use in every function switch to check what datatype it stores. Is there some easier way to do it?