Once the item has been stored in datanode it can be
retrieved by first interrogating the TAG field. See King P.
345-350 or K&R P. 148

What now if you wanted an array of such a variant record
structure?
(As indeed you might for the second assignment!)

typedef struct node* Nodeptr;

typedef struct node {
int TAG;
union {
int digits;
float number;
} data;
} Node ;

At this stage we have only a definition of a sample element
in our array. If we wanted to create M of them we would
first need to declare a pointer to such an element

Nodeptr np;
then get space for the array with
np = (Nodeptr) malloc (M*sizeof(Node));
or
np = (Nodeptr) calloc (M, sizeof(Node));

To access the zero'th TAG field we could write
kind = np->TAG;

while the i'th tag:
|