Hi,
I would like to code a simple linked list library with functions like adding and deleting nodes, sorting a list etc. Also I wish this library to be as general as possible.
Now my problem is, firstly functions like adding nodes result in a modification of the head pointer,
so if my main program looks like:-
How should I go about coding listlib.h?, right now i know that the create_list function should return struct node *, but what if someone else defines his nodes differently?Code:#include "listlib.h" struct node { char name[20]; unsigned int age; struct node *next; }; int main(void) { struct node *head=NULL; head=create_list(head); return 0; }
how do i generalize my library, so as to work around this issue?
Thanks,
Sahil



LinkBack URL
About LinkBacks



