#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main (int argc, char * const argv[]) {
vector<string> words;
int vectorlength = 0;
string input;
cout << "Enter \"done\" when done.\n";
cin >> input;
while (input.compare("done") != 0);
{
vectorlength++;
words.resize(vectorlength, input);
cin >> input;
}
return 0;
}
What I'm trying to do is store string values into a vector until the user enters done. But right now they can enter whatever they want and when they enter done, nothing happens. The cursor just moves to a new line. What's really strange is that if the first thing you enter is "done" and then you enter something else after it, the program quits.
Does anyone know why this is happening?


Sign In
Create Account


Back to top









