Home > Blockchain >  How to get an element in a map and change it
How to get an element in a map and change it

Time:02-14

How to get an element in a map and change it, for example if I have:

{'a', 100},  {'b', 200},  {'c', 300},  {'d', 400},  {'e', 500}

I want to get to get to the value of 'a' and change it from 100 to 105.

CodePudding user response:

map<char, int>::iterator it = m.find('a'); 
if (it != m.end() {
    it->second = 105;
  • Related