I need to exclude everything but 'a'-'z'.
Like:
dataFile.open(fileName, ios::in); dataFile >> word;
It imports each word until it hits a space character. How can I get it to stop importing when it hits spaces, underscores, periods, commas, etc..?
Thanks!
PS: Can you please not delete it this time? I want some help, not someone to write code for me. How did I ask for that? I have a whole program written and I need this to finalize it. It seems very simple.
EDIT:
Some additional code:
vector<WordFrequency> myVector;
fstream dataFile;
string fileName;
cout << "Enter the file name: ";
cin >> fileName;
dataFile.open(fileName, ios::in);
if (!dataFile)
{
cout << "ERROR: Cannot open file.\n";
return 0;
}
string word;
int frequency;
while (true)
{
dataFile >> word;
frequency=1;
myVector.push_back(WordFrequency(1,word));
if (dataFile.fail())
break;
}
I am doing the same assignment as another post in this forum. But I went about it different and it worked out to be easier (maybe not more efficient, but more on my level of experience). Basically I need to find the top 50 most common words. Words, not commas etc.. That is why I wish to exclude them to have a more working program.
This post has been edited by WickedBetrayal: 04 September 2012 - 10:47 AM

New Topic/Question
Reply




MultiQuote






|