It's a good idea for you to learn how to diagnose problems. You could have identified your problem by yourself by printing the contents of the map.
#include <iostream>
#include <map>
#include <string>
#include <vector>
int main() {
std::map<std::pair<int, int>, std::string> mymap;
for(int i = 0; i < 10; i = i + 2) {
std::pair<int, int> temp;
temp.first = i;
temp.second = i+1;
std::string temp2;
std::cout << "Enter a string: ";
std::cin >> temp2;
mymap[temp] = temp2;
}
std::map<std::pair<int, int>, std::string>::iterator iter = mymap.begin();
for ( ; iter != mymap.end(); ++iter )
{
std::cout
<< "Key: (" << iter->first.first << ", " << iter->first.second << "), Value: "
<< iter->second << std::endl;
}
while(1) {
int temp, temp2;
std::cout << "Enter a number: ";
std::cin >> temp;
std::cout << "Enter another number: ";
std::cin >> temp2;
std::pair<int, int> test;
test.first = temp;
test.second = temp2;
std::cout << mymap[test] << std::endl;
}
return 0;
}