1 2 3

A singly linked list

IMAGE imgs/link.ppt02.gif

IMAGE imgs/link.ppt01.gif

typedef struct node* Nodeptr; struct node {
int data;
Nodeptrnext;
};

......

Nodeptrmknode (int item)

{
Nodeptrnp;
np = (
Nodeptr) malloc (sizeof (struct node));
if (np != NULL) {
np->data = item;
np->next = NULL;
}
else exit (1);
return np;
}

1