#include #include // for ifstream #include #include "prompt.h" // find the longest word in a file specified by the user int main() { string word; // current word string maxword; // current longest word unsigned int maxlength = 0; // length of current longest word ifstream input; string filename = PromptString("enter name of file: "); input.open(filename.c_str()); // bind input to named file if (input.fail()) // if filename is invalid { cout << "cannot open " << filename << endl; return 0; //stop program } while (input >> word) // read succeeded { if (word.length() > maxlength) // if the next word in the file is the longest-so-far { maxlength = word.length(); // update maxýmum word length and maxword = word; // save the longest-so-far word } } if (maxlength != 0) { cout << "longest word is: " << maxword << endl << "and it has " << maxlength << " letters in it" <