It is the most basic operation to make the deletion of the single linked list node, this blog will be implemented to delete the node. Other operations can refer to the "C language to achieve the basic operation of the list" this blog. There are two types of deletes for a node:
 
(1) Delete a node of the I location;
 
(2) Determine if the X value is in the linked list, and delete the node if it exists;
 
The instance code has been uploaded to Https://github.com/chenyufeng1991/DeleteLinkedList.
 
The core code is as follows:
 
 
Deletes node *deleteposelement (nodes *pnode,int POS) of POS location {//requires a header node to maintain node *phead;
    Node *pmove;
    int i = 1;
        if (pos <= 0 | | | pos > sizelist (pnode)) {printf ("%s function execution, enter POS value illegal, delete node failed \ n", __function__);
    return NULL;
    } phead = Pnode;
    Pmove = Pnode;
        Consider deleting the first node individually if (pos = 1) {Pmove = pmove->next;
        Pnode = Pmove;
        Free (phead);
        printf ("%s function execution, delete Pos=1 location element succeeded \ \", __function__);
    return pnode;
        while (Pmove!= NULL) {if (i = = pos-1) {break;
        } i++;
    Pmove = pmove->next;
    Free (pmove->next);
    Pmove->next = pmove->next->next;
    printf ("%s function execution, delete pos=%d location element succeeded \ \", __function__,pos);
return pnode; //Determine if the X value is in the list, and if it exists delete the node node *deletexelement (node *pnode,int x) {//One of the last two pointers, Pmovepre is Pmove's previous node *pmovepre
    ;
    Node *pmove; if (Pnode = = NULL) {printf ("%s function execution, linked list is empty, delete x=%d failed \ \", __functiON__,X);
    return NULL;
    } pmovepre = Pnode;
    Pmove = pmovepre->next;
        Consider the first node if (pmovepre->element = = x) {pnode = Pmove separately;
        Free (PMOVEPRE);
    return pnode; while (Pmove!= NULL) {if (pmove->element = x) {//Find the previous node of the node Pmovepre->ne
            XT = pmove->next;
            Free (pmove);
        Break
        }//sync forward pmove = pmove->next;
    Pmovepre = pmovepre->next;
        } if (Pmove = NULL) {printf ("%s function execution, no x=%d, delete data failed \ n", __function__,x);
    return pnode;
    printf ("%s function execution, delete x=%d succeeded \ \", __function__,x);
return pnode;
 }