Question: C++ code. I am trying to input a text file: hi, thank you so much! you're the best! and search for the word best and

C++ code.

I am trying to input a text file: hi, thank you so much! you're the best!

and search for the word best and increment my counter to 1. However, I do not know how to ignor the exclamation point next to it.

Here is my code:

int Keyword(string fileName, char* token) { ifstream fin; fin.open(fileName); char word[30]; int count = 0; while (!fin.eof()) { fin >> word; if (!strcmp(word, token)) { count++; } } cout << "Number of matched words in file are " << count << endl; fin.close();

return count; }

My function returns 0. I need it to return one. Please help in C++.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!