All pastes #90508 Raw Edit

lee

public text v1 · immutable
#90508 ·published 2006-07-17 19:14 UTC
rendered paste body

#include <string>
#include <iostream>
#include <fstream>

using namespace std;

int main() {
	string filechoice;
	cout << "Enter file to search: ";
	cin >> filechoice;
	ifstream in("temp.cpp");
//	ifstream in(filechoice);
	string wordchoice;
	cout << "Enter word to search for: ";
	cin >> wordchoice;
	string word;
	int i = 0;
	while(in >> word)
		if (word == wordchoice)
			i++;
	cout << "There are " << i << " occurances of " << wordchoice << " in " << filechoice << "." << endl;
}