title: Comparing a variable to a linked list's variable
body: <p>I have a program where details are taken by a user for a survey. It contains details of a person with a pps as a unique identifier. When adding a newNode to the list and checking the PPS it does not recognise if the number is the same in any of the nodes. Adding a printf into the loop to show the current pps gives a nullptr exception. I have tried not using **head_ptr replacing with *head_ptr however this gives more errors down in the rest of the code where the node is added to the list.</p>
  
  <pre><code>//a new node is created which is filled with info. Some vaidation is done such as PPS number uniqueness and the node is added to the list
  //in this function the node is added to the very front of the list. Note: the sorting does not happen here without sorting it would be a list of the most recently enetered items
  //a second function will carry out the sort
  void addSurvey(struct survey** head_ptr)
  {
  
      int inputPPS,inputAge,inputSmoker, inputDrink, inputExer, inputIncome;
      int scanfBoolean;
      struct survey *temp;
      struct survey *newNode;
  
  
      temp = *head_ptr;
  
      newNode = (struct survey*)malloc(sizeof(struct survey));
      printf("\nPlease enter your PPS number (Number must be unique)\n");
      scanf("%d", &amp;inputPPS);
      while (temp != NULL)
      {
  
          if (inputPPS == temp-&gt;surveyDetails.ppsNo)
          {
              printf("\nPPS you have entered is not unique. \n\n");
              free(newNode); free(temp);
              return;
          }
          temp = temp-&gt;next;
          printf("\nChecking list. PPS is %d\n\n", temp-&gt;surveyDetails.ppsNo);
  
  
  
  
      }
      newNode-&gt;surveyDetails.ppsNo = inputPPS;
  </code></pre>