#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); } ofstream of; of.open("newanimals.txt"); if (of.fail()) { cout << "Can't create newanimals.txt\n"; exit(2); } int count = 0; while (true) { string s; f >> s; if (f.fail()) break; count = count + 1; of << s << "\n"; } cout << "There were " << count << " words in the file.\n"; f.close(); of.close(); }