Crosley33 Crosley33 - 1 year ago 120
C++ Question

cin strings into a Vector (c++)

So I am basically trying to the same thing 2 different ways.
The while loop is perfect but it stores the "." in the vector which I do not want to do but its the only way to exit the loop.

The second with the copy function; I don't know how to break or exit.
I believe this would help others.

Could I have some pointers in my investigation?
Thank you

while (keyinput != ".")
cin >> keyinput;


Answer Source

Use a do...while loop:

do {
    if (!(cin >> keyinput)) {
        // error handling...
    if (keyinput == ".") break;
while (true);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download