Hey I really need help with a project im working on. I can search for a single word in a single txt file, but I cant search for multiple words in multiple txt files. I am trying to create an array to store the words, which I read in from another text file. Any help would be great, thank you.
It's not really that hard. Just adjust it to the number of words you need to find, for more words, use more booleans, if you want to stop it after you found all words, use a loop with a break statement. You can also use multiple threads if you want to look for the words in the same time.
1 2 3 4 5 6 7 8 9 10 11 12 13
bool found=false;
while(std::getline(file1, line, ' '))
if(line=="word") found=true;
while(std::getline(file2, line, ' '))
if(line=="word") found=true;
//.... add as many files as you want
if(found) std::cout<<"The word exists in the given files";