I want to read all files in specific directory. for example In directory a there are file1.text file2.txt a.txt c.txt
I want to know how many words are included in each file. I made a code for a file. But I don't know how to automatically move on next file at same directory.
int EBook::get_total_words() {
ifstream ifs("inputs//a.txt");
int words = 0;
string word;
if (!ifs)
{
std::cout << "Unable to open file " << '\n';
exit(1);
}
while (ifs >> word) {
++words;
}
return words;
}