Monday, May 24, 2010

C program to insert new node at the end of singly linked list??

struct Node {


void *content;


struct Node *next;


};





void insert(const struct Node *list, void *content) {


struct Node *temp = list;


struct Node *newNode = (struct Node *) malloc(sizeof(struct Node));


newNode-%26gt;content = content;





// find last node


while (temp-%26gt;next) temp = temp-%26gt;next;


temp-%26gt;next = newNode;


}


No comments:

Post a Comment