Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions

Question

How are members held accountable for serving in the assigned roles?

Answered: 1 week ago