What I am trying to do is write a c++ statement that will give the user the option of entering up to seven separate sets of floating point numbers, each separated by a space, but less than seven if the user has less than seven floating point numbers they would like to enter instead. I then manipulate the input data.
cout << "Enter up to seven transactions for your groceries each separated by a space: "; \\How do I make it so they can enter less than seven if they wanted to?
The easiest way is to use a vector (or array if you must) and have the user enter 0 (or some other unallowed value like a negative number) to stop early.
The only thing I could add to what dutch has said is if say lines 10 - 24 are in a loop then you would need to use food.clear(); to empty the vector before the next use.