Craunch
0
Q:

check if map key has value cpp

if ( m.find("f") == m.end() ) {
  // not found
} else {
  // found
}
2
#include<map>

int main(){

  	map<int,char> m;
  	
  	char ch = '!';
  
	if (m.find(ch) != m.end()) {
		std::cout << "Key found";
	} else {
		std::cout << "Key not found";
	}
  
	return 0;
}
1

New to Communities?

Join the community