I had interviewed with a MNC company. He gave me the following code and asked me to make find() function as case sensitive. I tried but failed to understand how to make inbuilt find function as case sensitive. Is there any way to make it case sensitive to find only particular key value?
#include <iostream>
#include <map>
using namespace std;
int main()
{
map<string, int> mp;
mp["Test"] = 1;
mp["test"] = 2;
mp["TEST"] = 3;
mp["tesT"] = 4;
for(auto it = mp.find("TEST"); it != mp.end(); it++)
{
cout<<it->first<<" "<<it->second<<endl;
}
return 0;
}
Output :
TEST 3
Test 1
tesT 4
test 2
But I expect output only:
TEST 3
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire