//extract a word from fin ifstream& getWord(ifstream& fin, string& w) { char c; w = ""; // clear the string of characters while (fin.get(c) && !isalpha(c)) ; // do nothing. just ignore c // return on end-of-file if (fin.eof()) return fin; // record first letter of the word w += tolower(c); // collect letters and digits while (fin.get(c) && (isalpha(c) || isdigit(c))) w += tolower(c); return fin; }