title: Search function - Linked List
body: <p>I am working on a search function to search a linked list for a specific value. When it finds that value I want to output its position. I cannot seem to get past the first node without getting an error. I think something is wrong with the loops but I'm not sure what.</p>
  
  <pre><code>int NumberList::search(double num)
  {
      ListNode *nodePtr;
      nodePtr=head;
      int i=0;
      while (nodePtr-&gt;value!= NULL)
      {
          i=i+1;
          if (nodePtr-&gt;value==num)
              return i;
          else
              nodePtr=nodePtr-&gt;next;
      }
      return 0;  
  }
  </code></pre>