Hi,
I am trying to add item to a link list i am having trouble the head is always null, Please help!!!!
i am using the list in several functions
this is the link list defintion:
Code:typedef struct LinkList *ptr_fl; typedef struct LinkList { int linenumber; ptr_fl next; } Item; int main(int argc, char *argv[]) { ptr_fl *head=NULL; beforeInsert(&head); --here the head is null } void beforeinsert(ptr_fl *head) { add2list(head); } void add2list(ptr_fl *head) { ptr_fl p1 = *head; ptr_fl new_line = (ptr_fl)malloc(sizeof(FileLine)); new_line->linenumber = linenumber; new_line->next = NULL; if (p1 == NULL) { p1 = new_line; } else { while (p1->next != NULL) p1 = p1->next; p1->next = new_line; } return; }