Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <string>
- using namespace std;
- int count_the_word(string filename, string word)
- {
- int num_found = 0;
- ifstream data_file;
- data_file.open(filename.c_str());
- while(!data_file.eof())
- {
- string data;
- data_file >> data;
- if (data == word)
- {
- num_found++;
- }
- }
- data_file.close();
- return num_found;
- }
Add Comment
Please, Sign In to add comment