[Solved] Converting a code from c++ 11 to c++ 98?


  • Convert the range-based for to loops using iterator
  • Stop using auto and write the type manually

code:

#include <iostream>
#include <map>
#include <string>

int main()
{
    std::string input = "slowly";

    std::map<char, int> occurrences;

    for (std::string::iterator character = input.begin(); character != input.end(); character++)
    {
        occurrences[*character] += 1;
    }

    for (std::map<char, int>::iterator entry = occurrences.begin(); entry != occurrences.end(); entry++)
    {
        std::cout << entry->first << '=' << entry->second << std::endl;
    }
}

solved Converting a code from c++ 11 to c++ 98?