阅读背景:

仅将新数据添加到C中的链接列表

来源:互联网 
if (!head->next) {
    head->next = newNode;   /* if only dummy node, add node to end of list */
} else {
    /* iterates through linked list until a node is found that is greater than the new node */
    while (head->next && strcmpa((head->next)->data, newNode->data) < 0) 
        head = head->next;
    if (!head->next) {
        head->next = newNode;   /* adds new node to end list if no nodes are greater in value */    
    } else {
        newNode->next = head->next;     /* points new node to the next node */  
        head->next = newNode;   /* points current node to new node */
    }
}
if (!head->next) {
    head->next = newNode;   



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: