#include #include #include #include using namespace std; int main() { int count = 0; // counter variable vector words; // Use a vector of words ifstream in("sample_text"); // Open a file for reading string word; // a string variable to hold one word while(in >> word) words.push_back(word); for(int i = 0; i < words.size(); i++) { cout << words[i] << " "; count = i; } cout << "\nThe total number of words in the file was: " << count << endl; return 0; }