Quote Originally Posted by laserlight View Post

It's wrong. Test the delete function as a unit and it will be obvious. That is, write a main function that creates a linked list with three nodes. Use your delete function to delete the middle node. Now print the entire linked list starting fron the head.

My opinion is that:
In the function I wrote, the input always changeds(because of the function nexta), so, theorically, it should be able to remove nodes "in the middle".
This is just my opinion, but it doesn't have much importance because the program is not working.

However, this is how I would write a function to remove nodes which contains a specific value from a linked list (assuming that now all values are int):

Code:
 void remove_node(struct node **dptr, int n) {

         while (*dptr != NULL){
Code:
             if ((*dptr)->value != n)
                  *dptr = (*dptr)->next;

             else{
                 struct node *temp;
                 temp = *dptr;
                *dptr = (*dptr)->next;
                free (temp);
             }
     }
}


Is that correct in your opinion?