-
Make node code - right?
Code:
Node *MakeNode(StackE item)
{
Node *nptr;
if( (nptr = malloc ( sizeof nptr) ) != NULL)
{
nptr = item;
return item;
}
else
return NULL;
}
the structs for this are:
typedef int StackE;
typedef struct node{
StackEntry entry;
struct node *next;
}Node;
Returns: NULL if out of memory; otherwise a ptr to enough memory to hold a Node, with that node set to correct value(s), ready to be put on stack
Thanks
-
Code:
typedef int StackE;
Node *MakeNode (StackE item)
{
Node *nptr = NULL;
if (nptr = malloc (sizeof (Node)))
nptr->entry = item;
return nptr;
}