This is the error I get with using theMap.insert(line.substr(513,2));
Yes, insert() takes a std:pair<key_type, value_type>, in this case std:pair<std::string, int>. What's convenient though, is that the [] operator automagically inserts a new key/value pair into the map if one doesn't already exist with the same key. So when you reach this line:
Code:
(theMap[line.substr(513,2)])++;
If the ID/count pair weren't already inserted into the map, then it will automatically be inserted here, and then the value will be incremented. Also, I'm not 100% sure about this, but I believe it will initialize count to 0 when it is inserted (I ran a test and it initialized it to 0, but it might have just been because of debugging stuff the compiler added). So instead of doing an insert(), just put the ++ line in there.
In case it doesn't initialize it to 0 though, you can do this to ensure that it does what you want:
Code:
std::map<...>::iterator it = theMap.find(line.substr(523,2));
if(it == theMap.end()) //If no entries counted yet
theMap[line.substr(523,2)] = 1; //Then add it, and initialize it to a count of 1
else
(it->second)++; //Otherwise, increase the counter.
Just to note, (a map's iterator)->first is the 'key' of the pair, in this case the std::string that you use as the 'index', while ->second is the 'value' of the pair, in this case the int counter.
If you have any questions about how it all works, feel free to ask (I don't know how much of this you already know and understand, you seem to know a fair bit, so I won't explain unless you don't understand).
Hope this helps! :)