I'm having some trouble with reading in words from a file, and separating them into a multi-dimensional vector.
I am able to read the words in, but I need to be able to find where a space or carriage return occurs in the .txt file so I can separate each word and store them separately.
Code:
ifstream OpenFile("example.txt");
int pos = 0;
string str;
while(!OpenFile.eof())
{
getline(OpenFile, str);
cout << str;
string::size_type pos = str.find_first_of(" ");
while (pos != string::npos) {
cout << "Found space at: " << pos << endl;
pos = str.find_first_of(" .", pos + 1);
}
}
OpenFile.close();
That finds the space, but I don't know how to delete it.
Thanks for your help.