Use map::find
int keyToInsert = 2;
std::map<int, int>::iterator it;
it = yourMap.find(key);
if(it != yourMap.end()){
//alert user key exists
}
else {
//key doesn't exist
}
1
solved Counting Occurrences of integers in map c++ [closed]
Use map::find
int keyToInsert = 2;
std::map<int, int>::iterator it;
it = yourMap.find(key);
if(it != yourMap.end()){
//alert user key exists
}
else {
//key doesn't exist
}
1
solved Counting Occurrences of integers in map c++ [closed]