All pastes #922909 Raw Edit

Untitled

public text v1 · immutable
#922909 ·published 2008-02-29 02:40 UTC
rendered paste body
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;

int main() {
	int count = 0;				// counter variable
	vector<string> 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;
}