int count(struct node *first)
// first is a pointer to the first node
{
struct node *p = first;
int count = 0;
while(p)
{
++count;
p = p->link;
}
// Final value of count gives the number of nodes
// in the linked list.
return count;
}
Written by Munia Balayil
No comments:
Post a Comment