cout<<"Enter a word to be searched in the file words.txt:";
cin>>wordForQuery;
ifstream inFile;
inFile.open("words.txt");
string word;
while (inFile){
inFile >> word;
if (word == wordForQuery){
cout << "Found!"<<endl;
if (wordForQuery != word){
cout << "Not Found!" <<endl;
}
}
}
system("pause");
return 0;
}
======words.txt==============
there are some words in this file
that can be searched
==========================
Two things I need help with one is how do I make it so that if I type in searched for user input it wont display Found! twice but only once and second thing is how do I make the program instead displaying nothing when word can't be found to displaying "not Found!"