I a little new to istringstream operations. I need to find a way to iterate over words in a text file containing eight paragraphs. I need to get each words, test for certain conditions, and then store into a linked list if it passes the checklist. All I need help doing is how to extract each word one by one, use it, check it, and so forth. Here is some code I had: Could anyone lend some advice? I have a loop but it doesnt update the value of the string substrings, Thanks
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
using namespace std;
string getLineOfText(ifstream &strIn);
string parseLineOfText(string&);
int main()
{
ifstream in("Text.txt");
istringstream strI;
string substrings;
string strg;
int lineCount = 0;
while (!in.eof())
{
strg = getLineOfText(in);
++lineCount;
strI.str(strg);
while (strI >> substrings)
cout << substrings << " ";
strI.str("");
}
cout << substrings << endl;
cout << endl << lineCount << endl;
system("pause");
return 0;
}
string getLineOfText(ifstream &strIn)
{
string lineTxt;
getline(strIn, lineTxt);
return lineTxt;
}