So this is what I have tried doing. This is also the logic I mostly use to do word searching codes. I am basically seeing if I can find the character "g" and then I look if there are letters matching with good. If they are matching then I do count++ to count it and in the end I output my results:-
#include<iostream> //headers
#include<fstream>
using namespace std;
int main()
{
char arr[10000];
//declaration
fstream fileis;
fileis.open("fileis.txt",ios::in);
while (!fileis.eof( ))
{ //reading loop
fileis>>arr;
cout<<arr<<endl;
}
int count=0;
for(int i=0; arr[i] != '\0'; i++) //main loop
{
if(arr[i] == 'g' && arr[i+1] == 'o' && arr[i+2] == 'o' && arr[i+3] == 'd') //condition to check if the word is there
{
count++;
}
}
fileis.close();
cout<<"The word good appeared "<<count<<" times."<<endl;
return 0;
}