I am supposed to read(scan) data from a folder with multiple(21578) text files, and file names are numbered from 1 to 21578,and read each word that occurs in a text file, and count the number of times it occurs in the entire folder,i.e; in all the files how do i go about it? Plz help.
i've tried this so far..but it isn't working..
#include <iostream>
#include <map>
#include <string>
using namespace std;
void incrementString(map<string, int> &theMap, string &theString) {
if(theMap.count(theString)) {
theMap[theString]++;
} else {
theMap[theString] = 1;//This fixes the issue the other poster mentioned, though on most systems is not necessary, and this function would not need an if/else block at all.
}
}
void printMap(map<string, int> &theMap) {
map<string, int>::iterator it = theMap.begin();