I am working on a program in C++ for my class to prepend, append, insert, display items of a circular-list. I came across while loop functioning differently then a do-while loop for what to my mind would potentially output the same items. I am looking for an explanation to why the output is different with the code blocks below, thank you. If you have places were I can modify code to enhance it please let me know trying to build as much information as possible again Thank You.
Link to full code: Pastebin
while(temp != head)
{
cout << temp->data << " ";
temp = temp->next;
}
Output: Nothing
do
{
cout << temp->data << " ";
temp = temp->next;
}while(temp != head);
Output: 10 20