I am getting the continuous prompt now in the console and when I enter -1 it breaks out of the loop but it skips to line 55. I cannot figure out how to have it skip over this problem. If I change the 0 in line 55 to a number besides 0 I get an output but the numbers are all wrong.
I feel like I am looking over an obvious problem :(
while (true)
{
// create a node
Score* aScore = new Score;
cout << "Enter score " << (i + 1) << " [-1 to quit]: ";
cin >> aScore->value;
cin.ignore(1000,10);
// check for sentinal value
if (aScore->value == -1) break;
// add node to list (stack model)
aScore->next = head;
head = aScore;
// sum the scores
scoreTotal += aScore->value;
i++;
count++;
}
Thanks you have been super helpful! One last question but I'm having difficulty getting rid of my old "for loop".
Lines 24-28 are not needed though when I delete that "if" loop I am receiving a ton of compiling errors. However isn't the "for" loop starting from line 31 necessary for my program to work properly?
So I copy and pasted your code, I didn't really add any lines of code I just deleted most of the for loop and moved some needed things from it to the while loop.
I tested it and it works, I'm just going to paste the entire thing here since its hard to explain where everything was moved, but the only changes are in the while loop and for loop. So it should be pretty easy to see the changes