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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started