title: linked list adding to the tail, confusion
body: <p>Visual Studio 2008 C </p>
  
  <p>What I can't understand about this linked list is the adding to the tail in the else part of the if statement.</p>
  
  <p>When the head and tails is assigned the memory address of the node_temp to both tail and head both point to the same memory location.</p>
  
  <p>However, in the else part is the head in fact still pointing to the tail. There is just something I can't explain and don't understand about the else part?</p>
  
  <p>I hope some one can explain better for me.</p>
  
  <pre><code>static struct convert_temp
  {
      size_t cel;
      size_t fah;
      struct convert_temp *next;
  } *head = NULL, *tail = NULL;
  
  /** Add the new converted temperatures on the list */
  void add(size_t cel, size_t fah)
  {
      struct convert_temp *node_temp = NULL; /* contain temp data */
  
      node_temp = malloc(sizeof(*node_temp));
  
      if(node_temp == NULL)
      {
          fprintf(stderr, "Cannot allocate memory [ %s ] : [ %d ]\n",
              __FUNCTION__, __LINE__);
          exit(0);
      }
  
      /* Assign data */
      node_temp-&gt;cel = cel;
      node_temp-&gt;fah = fah;
      node_temp-&gt;next = NULL;
  
      if(head == NULL)
      {
          /* The list is at the beginning */
          head = node_temp;   /* Head is the first node = same node */
          tail = node_temp;   /* Tail is also the last node = same node */
      }
      else
      {
          /* Append to the tail */
          tail-&gt;next = node_temp;
          /* Point the tail at the end */
          tail = node_temp; 
      }
  }
  </code></pre>