c - Can same linked list function that adds to end of the list be used to add to many diffrent linked lists? -
this linked list function adds new node end of list.
void addnodeattail( struct student *student, struct courses *newnode ) { newnode->next = null; // sucessor of newnode null, because newnode becomes tail of list if ( student->list == null ) student->list = newnode; // if list empty, newnode head of list else { struct courses *temp = student->list; while( temp->next != null ) // search last element in list temp = temp->next; temp->next = newnode; // successor of last node newnode } } can same function used adding node diffrent linked list may have? or have create function because dealing struct?
if object trying add not struct courses *newnode not able add function. if need generic linked list need mess around passing void * lots of fun. here reasonable tutorial this:
Comments
Post a Comment