The problem of structure pointers as function parameters?

void ListDelete(LinkList *q,LinkList *p){
    (*q)->next=(*p)->next;
    free(*p);
    (*p)=(*q)->next;
}

and then directly ListDelete (& pjingheq) will be fine.
but my head pointer is also passed directly, (LocateElem (Linklist head.)). Deleting elements here does modify the linked list in the main function. Why

CPP c
Jul.29,2021

the first post was reviewed for nearly 12 hours. In other forums, dalao helped me solve the
problem. The
problem lies in pairq-> next in the ListDelete function. This is the assignment of the parameter address, which cannot modify the p point in the locateElem function at all. You can change the value of the address it points to through the parameter pointer, rather than directly modify the value of the parameter pointer.
it would be even better if dalao could help analyze how secondary pointers solve this problem!

Menu