Hi,
I am loading in a dictionary text file of English words, but I am not supposed to load any words if they contain an apostrophe. I am loading them in as strings, and I cannot figure out how not to load the string if it contains an apostrophe. Here is my code. Thanks.
class Dictionary
{
private:
ifstream in;
string word;
int numOfWords;
public:
Dictionary();
~Dictionary(void);
void Load(const char* filename);
};
void Dictionary::Load(const char* filename)
{
numOfWords = 0;
in.open(filename);
if (!in.is_open())
{
cout << "ERROR! Cannot locate file: " << filename << '\n';
return;
}
HTable<string> hTable(NUMOFBUCKETS,Hash);
while(true)
{
getline(in, word, '\n');
if(in.eof())
break;
// All words read in must be 3 to 6 characters long
if(word.length() > 2 && word.length() < 7)
{
hTable.insert(word);
++numOfWords;
}
}
cout << "Number of words loaded into dictionary Hash table: " << numOfWords << endl;
}