I am trying to run what i thought was a pretty basic program to solve a problem concerning strings (besides the point). It turns out that my algorithm works properly but i am stuck on a detail; the following segment of code is the problem:
int cases;
string line;
vector<string> frags, results;
cin >> cases;
while ( cases > 0 ) {
while (cin >> line){
frags.push_back(line);
line = "";
}
results.push_back( find_original(frags) );
//find_original does not modify frags, and returns a string
frags.clear();
cases--;
}
the problem occurs when i input a value of 'cases' that is higher than 1. the error occurs during the second run-through when the program hits the inner while loop. I get a debugger error telling me that a vector iterator is not dereferenceable. Any help is greatly appreciated.