Nodeptr mknode (int value)
{
Nodeptr np;
//np = (Nodeptr) malloc (sizeof (Node));
np = (Nodeptr) malloc (sizeof (struct node));
if (np != NULL) {
np->data = value;
np->next = NULL;
}
return np;
}
Sometimes we want one field in a data structure to hold
two values of different type. Say for instance either an
integer or a float. We can do this through the use of a
union--forming something much like a variant record in
Pascal.
|