i have been trying to erase those pairs in map whose value is 0.......but the program would just stop working at that point.......
here is d short code.......
#include <map>
int main()
{
map<string,int> mapa;
map<string,int>::iterator p;
........
............
When you erase the iterator it will point at the next entry. So if the last one is 0 it'll go 1 past end and the for loop will fail causing a crash etc..
if ((*p).second == 0) {
mapa.erase(p);
p--;
continue;
}
is a dirty way to do it. I'd look at a better option myself.