Hi,
I have 3 pointers on the same linked list,
named ptr, ptra, ptragain.
I'd like to be able to swap data from ptr to ptra, and from ptra to ptr, thus the need for the temporary ptragain.
Here is a slice of the code, that throws a Segmentation error.
Can you help me with this please? Cant see where I'm going wrong.
thanks
chris
I have 3 pointers on the same linked list,
named ptr, ptra, ptragain.
I'd like to be able to swap data from ptr to ptra, and from ptra to ptr, thus the need for the temporary ptragain.
Here is a slice of the code, that throws a Segmentation error.
Can you help me with this please? Cant see where I'm going wrong.
Code:
ptra=ptr->next;
ptragain=ptra->next;
if(ptra->count > ptr->count){
//ptragain=ptr;
ptragain->count = (ptr->count);
*ptragain->word = *ptr->word;
//ptr=ptra;
ptr->count = ptra->count;
ptr->word = ptra->word;
//ptra=ptragain;
ptra->count = ptragain->count;
ptra->word = ptragain->word;
}
chris