map<string, string> m;check key exist or not, and return number of occurs(0/1 in map):
int num = m.count("f"); if (num>0) { //found } else { // not found }check key exist or not, and return iterator:
map<string,string>::iterator mi = m.find("f"); if(mi != m.end()) { //found //do something to mi. } else { // not found } in your question, the error caused by bad operator<< overload, because p.first is map<string, string>, you can not print it out. try this:
if(p.first != p.second) { cout << p.first->first << ""<< p.first->second << endl;}