title: Getting an unexpected breakpoint when trying to print a doubly linked list
body: <p>I am getting an unexpected break point when I am trying to print out my doubly linked list. The unexpected break point is popping out in the <code>printSongInfo</code> function in the dsA1LL.cpp on the line</p>
  <pre><code>while (ptr != NULL) {
      printf(&quot;%-35s %-35s %-35d\n&quot;, ptr-&gt;title, ptr-&gt;artist, ptr-&gt;rating);
      ptr = ptr-&gt;next;
  }
  </code></pre>
  <p>//New just added
  I completed some changes to the piece of code and now it not printing out the list. It is only printing out the first Node.</p>
  <p>This will only print one line then the break point appears. I am wondering if it is the <code>printSongInfo</code> function or if it is the doubly linked list function <code>getSongInfo</code> causing the issue.
  Source code dsA1.cpp file</p>
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;string.h&gt;
  #include&lt;stdlib.h&gt;
  #include&lt;malloc.h&gt;
  #include&quot;dsA1.h&quot;
  #pragma warning(disable : 4996)
  #pragma warning(disable : 6387)
  
  
  int main() {
  
  
      char title[kStringLength];
      char artist[kStringLength];
      int rating = 0; 
      SongNode* head = NULL; 
      SongNode* tail = NULL; 
  
  
  
      printf(&quot;Enter Title, Artist and Rating\n&quot;);
      printf(&quot;Enter'.' to get out of the loop and print list\n&quot;);
      
      while (kInfiniteLoop) {
  
          printf(&quot;Title: &quot;); 
          fgets(title, kStringLength, stdin); 
          eliminateEndOfLine(title); 
  
          if (strcmp(title, &quot;.&quot;) == 0) {
              break;
          }
  
          printf(&quot;Artist: &quot;); 
          fgets(artist, kStringLength, stdin);
          eliminateEndOfLine(artist);
              
          printf(&quot;Rating: &quot;); 
          while (rating = getNum()) { // error check the rating this will check to make sure the rating is in the range 1-5.
  
              if (rating&lt;1||rating&gt;5){
                  printf(&quot;The number you have entered is invaild\n&quot;);
                  rating = 0; 
                  printf(&quot;Rating: &quot;); 
                  continue; 
              }
              break; 
          }
          head = getSongInfo(head, title, artist, rating); 
      }
      
      printSongInfo(head); 
      return 0;
  }
  </code></pre>
  <p>dsA1.h header file</p>
  <pre><code>#pragma once
  
  //structs 
  typedef struct SongNode {
      char* title;
      char* artist;
      int rating; 
      SongNode* next;
      SongNode* prev; 
  }SongNode;
  
  //Constants 
  #define kInfiniteLoop 1 
  #define kStringLength 30
  
  //Prototypes
  SongNode* getSongInfo(SongNode* head, char title[kStringLength], char artist[kStringLength], int rating);
  void printSongInfo(SongNode* head); 
  int getNum(void); 
  void eliminateEndOfLine(char* buffer); 
   
  </code></pre>
  <p>dsA1LL.cpp other source code file</p>
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;string.h&gt;
  #include&lt;stdlib.h&gt;
  #include&lt;malloc.h&gt;
  #include &quot;dsA1.h&quot;
  #pragma warning(disable : 4996)
  #pragma warning(disable : 6387)
  
  SongNode* getSongInfo(SongNode *head, char title[kStringLength], char artist[kStringLength],int rating) {
      
      SongNode* newNode; 
      newNode = (SongNode*)malloc(sizeof(SongNode));
      if (newNode == NULL) {
          printf(&quot;No Memory left\n&quot;); 
          return head;
      }
  
      newNode-&gt;title = (char*)malloc(strlen(title) + 1); 
      if (newNode-&gt;title == NULL) {
          printf(&quot;No memory left for title\n&quot;); 
          return head; 
      }
  
      newNode-&gt;artist = (char*)malloc(strlen(artist) + 1); 
      if (newNode-&gt;rating == NULL) {
          printf(&quot;No memory left for artist\n&quot;); 
          return head; 
      }
  
      
      strcpy(newNode-&gt;title, title); 
      strcpy(newNode-&gt;artist, artist);
      newNode-&gt;rating = rating; 
  
      if (head == NULL) {
          head = newNode;
          return head; 
      }
  
      head-&gt;prev = newNode;
      newNode-&gt;next = head; 
      
      return head; 
  }
  
  void printSongInfo(SongNode* head) {
      SongNode* ptr;
      ptr = head;
  
      printf(&quot;\n&quot;);
      printf(&quot;%-35s %-35s\n&quot;, &quot;Title&quot;, &quot;Artist&quot;);
  
      while (ptr != NULL) {
          printf(&quot;%-35s %-35s %-35d\n&quot;, ptr-&gt;title, ptr-&gt;artist, ptr-&gt;rating);
          ptr = ptr-&gt;next;
      }
  }
  
  
  /*===============================================================================================================*/
  /*FUNCTION   :getNum(void)                                                                                       */
  /*PARAMETERS :void                                                                                               */
  /*RETURNS    :number                                                                                             */
  /*DESCRIPTION:This function is the user input function to get a number rating                                    */
  /*===============================================================================================================*/
  int getNum(void)
  {/* the array is 121 bytes in size; we'll see in a later lecture how we can improve this code */
      char record[121] = { 0 }; /* record stores the string */
      int number = 0;
      /* NOTE to student: indent and brace this function consistent with your others */
  /* use fgets() to get a string from the keyboard */
      fgets(record, 121, stdin);
      /* extract the number from the string; sscanf() returns a number
   * corresponding with the number of items it found in the string */
      if (sscanf(record, &quot;%d&quot;, &amp;number) != 1)
      {
          /* if the user did not enter a number recognizable by
           * the system, set number to -1 */
          number = -1;
      }
      return number;
  }
  
  
  
  /*=======================================================================================================*/
  /*FUCNTION      :void eliminateEndOfLine                                                                 */
  /*PARAMETER     :(char* buffer)                                                                          */
  /*RETURNS       :void                                                                                    */
  /*DESCRIPTION   :This function takes a pointer to a string and looks through the string to find the      */
  /*               newline.It takes the new line out of the string.                                        */
  /*=======================================================================================================*/
  void eliminateEndOfLine(char* buffer)
  {
      char* target = strchr(buffer, '\n');
      if (target != NULL)
      {
          *target = '\0';
      }
  }
  </code></pre>