I was experimenting with a direct method of dereferencing an iterator.
It works OK with numbers, cout gets confused (??) when the derefenced pointer is a string?
The code was supposed to stuff a vector, then read it out . I hacked up that original to do some troubleshooting and it came down to the iterator.
How can this method be used with a string? -or can it?
#include <iostream>
#include <string>
#include <vector>
using namespace std;
vector <string> strv;
int main()
{
string input;
vector <string>::iterator itr = strv.begin();
do
{
getline (cin,input);
strv.push_back(input);
}
while(input !="x");
cout << "exited first loop" << endl;
while (itr != strv.end())
{
cout << *itr++ << endl;//cout crashes here
}
return 0;
}