hash_map is, unfortunetely, not standardized C++.
Quick browsing of the MSDN shows that hash_map has the same interface as std::map. The following code should work interchangably with map and hash_map, assuming you change the include and typedef appropriately.
What you want to do is read keys from one file, and values from another (you don't tell which way you want the search to work, I'd assume from person to phone number).
Code:
#include <map>
#include <fstream>
#include <iostream>
#include <string>
typedef std::map<std::string, std::string> phonebook_t;
int main() {
phonebook_t phonebook;
std::ifstream people_stream("people.txt");
std::ifstream numbers_stream("numbers.txt");
std::string person;
std::string number;
while (people_stream >> person && numbers_stream >> number) {
phonebook[person] = number;
}
phonebook_t::iterator i;
for (i = phonebook.begin(); i != phonebook.end(); ++i){
std::cout << i->first << " -> " << i->second << std::endl;
}
// find Rob's number
phonebook_t::iterator found = phonebook.find("Rob");
if (found != phonebook.end()) {
std::cout << "Rob's number is " << found->second << '\n';
} else {
std::cout << "Rob is not in phonebook\n";
}
return 0;
}