Alright, I'm working on a project at the moment where I am trying to take a map and populate it with user input through a function. I under stand the basic way of populateing it by simply having something like...
typedef map< string, string> strMap;
strMap["key"] = 'value';
however, I want it to do something like...
typedef map< string, string> strMap;
int addMap(string Fname, string Lname)
{
//where Fname and Lname are strings entered by the user in main that hold someone first and last names respectively.
strMap[Fname] = Lname;
}
int main()
{
char Fname[20], Lname[20];
map m;
cout << "enter your first name: ";
cin.ignore();
cin.getline(Fname, 20);
cout << "enter your first name: ";
cin.ignore();
cin.getline(Lname, 20);
m.addMap(Fname, Lname);
}
does anyone know a way to accomplish this with a map?