#include #include #include using namespace std; int main() { ifstream f; f.open("animals.txt"); if (f.fail()) { cout << "Can't open animal.txt\n"; exit(1); } int count = 0; while (true) { string s; f >> s; if (f.fail()) break; count = count + 1; cout << "Read from file: " << s << "\n"; } cout << "There were " << count << " words in the file.\n"; f.close(); }