I am trying to access the first key and value stored in my name_to_email. However, an "Segmentation fault (core dumped)" error message is showing up. Any suggestions on how to do this?
#include <iostream>
#include <map>
usingnamespace std;
/*Implement a small address book program that allows users to enter names and email addresses, remove or change entries,
and list the entries in their address book. don't worry about saving the address book to disk; it's ok to lose the data
when the program exits*/
int main ()
{
string name;
string email_address;
map <string, string> name_to_email;
map <string, string> :: iterator itr = name_to_email.begin ();
itr = name_to_email.begin ();
cout << "Enter name: ";
cin >> name;
name_to_email[name];
cout << "Enter " << name << "'s " << "email address: ";
cin >> email_address;
name_to_email[name] = email_address;
cout << itr->first;
return 0;
}