I've been working my way through SAMS teach yourself C for Linux programming over the last year and have recently been studying linked lists.
To delete from the middle of a linked list the book says to do this:
struct person *current1, *current2;
You should go through the list until current1 points to the element before the one you want to delete then:
current2 = current1->next;
current2 now also points to the element.
current1->next = current2->next;
What I am not understanding though is the above. current2 points to the memory current1->next points to, when you free current1->next you are deallocating the memory that current2 points to and current2->next would havel be stored here so how can you be expected to you assign current current2->next to current1->next if you have dellocated the memory current2 points to?