title: How does the code actually for inserting a node when a node already exists
body: <p>After inserting a node, *sPtr which is the head pointer that points to the first node, how does the code actually work for inserting a second node? i understand the while loop is going through the nodes, checking if current is equals to null which is equals to the contents of *sPtr and if the value entered is bigger than current's data. but what i don't understand is the if else statement part after it. The if i get it's putting the newPtr to the beginning of the list, but the else part where previousPtr->nextPtr = newPtr;
  newPtr->nextPtr = currentPtr; how does this link the node existing *sPtr - > [existing node] to the newly created previous and current node that has jsut been assigned? </p>
  
  <pre><code>void insert(ListNode* *sPtr, char value)
  { 
     ListNode* newPtr = malloc(sizeof(ListNode)); 
  
     if (newPtr != NULL) { 
        newPtr-&gt;data = value; 
        newPtr-&gt;nextPtr = NULL; 
  
        ListNode* previousPtr = NULL;
        ListNode* currentPtr = *sPtr;
  
  
        while (currentPtr != NULL &amp;&amp; value &gt; currentPtr-&gt;data) {
           previousPtr = currentPtr;            
           currentPtr = currentPtr-&gt;nextPtr; 
        }                                          
  
        // insert new node at beginning of list
        if (previousPtr == NULL) { 
           newPtr-&gt;nextPtr = *sPtr;
           *sPtr = newPtr;
        } 
        else { // insert new node between previousPtr and currentPtr
           previousPtr-&gt;nextPtr = newPtr;
           newPtr-&gt;nextPtr = currentPtr;
        } 
     } 
     else {
        printf("%c not inserted. No memory available.\n", value);
     } 
  } 
  </code></pre>
  
  <p>i'm not sure if i'm making sense but it's jsut really confusing for me. Appreciate any explanation thanks in advance!! :)</p>