#include <stdio.h>
#include <stdlib.h>

#define LEN 10

typedef enum {
    INT_TYPE,
    FLOAT_TYPE,
	POINTER_TYPE
} DataType;

typedef union {
    int i;
    float f;
	void *p;
} Data;

struct MyStruct{
	Data data;
	DataType type;
};

void 
printData(struct MyStruct *array, int size) {
    for (int i = 0; i < size; i++) {
        switch (array[i].type) {
            case INT_TYPE:
                printf("%d)int: %d\n", i, array[i].data.i);
                break;
            case FLOAT_TYPE:
                printf("%d)float: %f\n", i, array[i].data.f);
                break;
           	case POINTER_TYPE:
				 printf("%d)ptr: %p\n", i, array[i].data.p);
                break;
        }
    }
}

int
main()
{	
	struct MyStruct *array = NULL;
	array = (struct MyStruct* )malloc(LEN * sizeof(struct MyStruct)); 
	int n = 12;
	for(struct MyStruct *iter = array; iter < array+LEN; iter++, n++)
	{
		if (n % 3 == INT_TYPE){
			iter->type = INT_TYPE;
			iter->data.i = n;
		}else if (n % 3 == FLOAT_TYPE){
			iter->type = FLOAT_TYPE;
			iter->data.f = n/3.0;
		}else if (n % 3 == POINTER_TYPE){
			iter->type = POINTER_TYPE;
			iter->data.p = iter;
		}
	}
	printData(array, LEN);
	return 0;
}
