list

hello,

I have tried to fixed the following sort function for my linked list but unfortunately i can't get it to work. What is happening is that it keep deleting the node that need to be moved but when i add a node to the end then it sort everything except the head of the list. So any help will be greatly appreciated.

this is the struct to let you have and idea of the list:
1
2
3
4
5
6
7
/*setting up structure*/
 struct member_account{
     char member_last[MAX_LENGTH ];
     char member_first[MAX_LENGTH];
     double member_balance;
     struct member_account *next;
};
Last edited on
I know where the problem is. The problem occurs when I swap the nodes around. I have tried different things but can't get the swap working.
Your problem is because you need to pass the address of the head of the list. i.e. you should do struct member_account *sort(struct member_account **list)
THANKS YOU so much for your help. I figured it out thanks for your help.
Topic archived. No new replies allowed.