2 struct pointers (Double link list)
typedef struct node
{
int value;
struct node *next;
struct node *prev;
}mynode ;
// Function to add a node
void add_node(struct node **head, int value)
{
mynode *temp, *cur;
temp = (mynode *)malloc(sizeof(mynode));
temp->next=NULL;
temp->prev=NULL;
if(*head == NULL)
{
*head=temp;
temp->value=value;
}
else
{
for(cur=*head;cur->next!=NULL;cur=cur->next);
cur->next=temp;
temp->prev=cur;
temp->value=value;
}
}
Thursday, April 8, 2010
Function to add node to double link list
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment