combining map and array of string c++
arrays, c++, dictionary
Solution
Data structure like `map<string, vector<string> >` will work.
You can use `for (size_t i = 0; i < it->second.size(); i++)` to traverse the vector.
Problem
I'm writing a code to check if a person has visited a particular place before or not. If true, do nothing. Otherwise, add the new place to the list of visited place I'm using map to store the student name as a key and array the store places as follows, ``` #include<map> using namespace std; map<string,string[]> stu_plac; map<string,string[]>::iterator it; ``` I could not find the right way to search across the map. I tried the following: ``` bool exist=false; if(stu_plac.count(name)) { it=stu_plac.find(name); for(auto tt=(*it).second.begin(); tt!=(*it).second.end(); tt++) { if (tt.compare(place)==0)//exist { exist=true; } break; } if (!exist) { (*it)second[++tt]=place; } } else { stu_plac.insert(pair<string,string[]>(name,place)); } ``` I think the problem is with the array of string iterator. Can you please help me to find the correct way to do this. Do I need to use multimap or other data structer to do this??