#include #include #include #include using namespace std; void fill_phonebook(map& phonebook, string datafile); void search_phonebook(map& phonebook); int main() { map phonebook; fill_phonebook(phonebook, "phonebook.dat"); cout << "Suzanne's Number: " << phonebook["Suzanne"] << endl; search_phonebook(phonebook); } void fill_phonebook(map& phonebook, string datafile) { ifstream fin; int size; //Size of phonebook int i; //Loop control string name; string number; fin.open(datafile.c_str()); if(!fin) //Check that the file was opened correctly { cerr << "Cannot open file " << datafile << endl; exit(0); } fin >> size; fin.ignore(); //Gets rid of extra newline for(i=0; i& phonebook) { string name; for(;;) { cout << "Type a name, please: "; getline(cin, name); cout << name << "'s number: " << phonebook[name] << endl; } }