I have an input.txt file which consists of words and numbers
Helicopter 12 HELICOPTER 555 Helicopter 12 555 vehicle 555 Vehicle 13 14 15 15 YACHT
And I have a program which converts it into two std::map, one - for words, another one - for numbers, where the key is a word(number) and value is how many times it appears in input.txt
map<string, int> text, num;
string buff;
ifstream input("input.txt");
if (!input)
{
cout << "No file was found\n";
return 1;
}
while (input >> buff) {
if (all_of(buff.begin(), buff.end(), isdigit)) num[buff]++;
else text[buff]++;
}
The thing is I need to make it case insensitive, so 'HELICOPTER' and 'helicopter' would be considered the same kind of word and counted as 2
I tried using for_each() + tolower() for 'text', but it didn't work, the error was:
cannot convert 'std::pair<const std::__cxx11::basic_string<char>, int>' to 'int' in argument passing
I was wondering how can I do it. And I also think it might be better if I convert input.txt tolower before making maps out of it, but I couldn't find a method to do it