title: calling a function within another function
body: <p>I am making a simple linked list with an insert function that has 4 conditions:</p>
  
  <ol>
  <li>add in the middle of the list</li>
  <li><p>add to the head if the list is not empty</p></li>
  <li><p>add to an empty list</p></li>
  <li>add to the end of a list</li>
  </ol>
  
  <p>I have made an addNode function that takes care of the last two conditions and im trying to implement it inside of the insertNode but it keeps crashing? is there any specific reason or am I just missing something simple?</p>
  
  <p><strong>addNode:</strong></p>
  
  <pre><code>void linkList::addNode(int dataAdd) // this only adds a node to the end
  {
      nodePtr n = new node; // what this does is make the node pointer 'n' point to this new node
      n-&gt;next = NULL;
      n-&gt;data = dataAdd;
  
      if (head != NULL)
      {
          follow = head;
          while (follow-&gt;next != NULL)
          {
              follow = follow-&gt;next;
          }
          follow-&gt;next = n;
      }
      else
      {
          head = n;
      }
  
  }
  </code></pre>
  
  <p><strong>insertNode:</strong></p>
  
  <pre><code>void linkList::insertNode(int dataInsert)
  {
      nodePtr n = new node;
      n-&gt;next = NULL;
      n-&gt;data = dataInsert;
  
      follow = head;
  
      while (follow != NULL)
      {
          trail = follow;
          follow = follow-&gt;next;
  
          if (head-&gt;data &lt; dataInsert){
              n-&gt;next = head; //n's next will become the current head (n is now the first item in the linkList)
              head = n;       //n the head structure will now be n (n is the new head)
          }
  
          else if (follow-&gt;data &lt; dataInsert)
          {
  
              trail-&gt;next = n;
              n-&gt;next = follow;
              break;
          }
          else
          {
              addNode(dataInsert);
          }
  
      }
  }
  </code></pre>
  
  <p>I want to call addNode in the <strong>else</strong> statement in <strong>insertNode</strong></p>