Q:

Add only new data to linked list in 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 */
    }
}

How can I edit this code to get it to reject any new node whose data field is equal to a node that is already in the list? 

A:

change the last else { into
else if(strcmp(head->next->data, newNode->data)) {

