title: doubly linked list in C, overlooks final entry, or wants one where there is none
body: <p>I have been studying C out of Kochan's Programming in C 4th edition.  I'm trying to strike a balance between bashing my head against a wall for hours and asking for insights.</p>
  
  <p>I am in the chapter on pointers, the exercises have you build a number of functions, then expand to a doubly linked list.  One item is having the list point front to back and back to front.  My issue is that when going from front to back, the last entry displays a value where I want to skip the value.  Same going the other direction.  The methodology I had been using is to have a node entry at the front and back for the sake of being able to add entries to the beginning and end of the list.   Just a note, we have not reached memory allocation or the like.  Also I left in my insert function just in case there is some problem there.  Thanks in advance</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdbool.h&gt;
  
  struct entry
    {
        struct entry *previous;
        int      value;
        struct entry *next;
    };
  
  void insertEntry(struct entry *what, struct entry *where)
  {
      what-&gt;next = where-&gt;next;
      what-&gt;previous = where-&gt;previous;
      where-&gt;next = what;
      where-&gt;previous = what;
  }
  
  void printEntries_Reverse (struct entry initial)
      {
          while (initial.previous != NULL){
              printf("%i  \n", initial.previous-&gt;value);
              initial.previous = initial.previous-&gt;previous;
          }
      }
  
  void printEntries(struct entry initial)
  {
       while (initial.next != NULL){
          printf("%i   \n", initial.next-&gt;value);
          initial.next = initial.next-&gt;next;
  }
  printf("\n");
  }
  
  int main (void)
  {
    struct entry head, foot, n0, n1, n2, n3, n4, nx;
  
    struct entry *list_ptr, *list_end;
  
    list_ptr = &amp;n0;
    list_end = &amp;n4;
  
      n1.value = 100;
      n2.value = 200;
      n3.value = 300;
      n4.value = 400;
  
  
      n0.next = &amp;n1;
      n1.next = &amp;n2;
      n2.next = &amp;n3;
      n3.next = &amp;n4;
      n4.next = NULL;
  
  
      n0.previous = NULL;
      n1.previous = &amp;n0;
      n2.previous = &amp;n1;
      n3.previous = &amp;n2;
      n4.previous = &amp;n3;
  
      nx.value = 250;
  
      insertEntry(&amp;nx, &amp;n2);
      printEntries(*list_ptr);
      printEntries_Reverse(*list_end);
  
    return 0;
  }```
  </code></pre>