Horje
store words of a string in map Code Example
store words of a string in map
int main()
{
    std::string input="Hello My name is OP Hello World";
    std::map<std::string, int> myMap;
    std::istringstream iss(input);
    while (iss) {
        std::string substr;
        std::getline(iss,substr,' ');
        int count = 0;
        auto pos = input.find(substr, 0);
        while (pos != std::string::npos) {
            ++count;
            pos = input.find(substr, pos + 1);
        }
        if(substr.size() != 0)
            myMap[substr] = count;
    }
    for (const auto &p : myMap) {
        std::cout << p.first << "=" << p.second << '\n';
    }
    return 0;
}




Whatever

Related
East Virginia. Code Example East Virginia. Code Example
regex for kazakhstan numbers Code Example regex for kazakhstan numbers Code Example
findplacefromtext google api Code Example findplacefromtext google api Code Example
adding extra ram to esp32 Code Example adding extra ram to esp32 Code Example
when was bread invented Code Example when was bread invented Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
6