Q:

Print C++ Map by iteration

Is there an easier way to go about this or is there something I'm doing horribly wrong? I think that the core of my problem is in the code, 
vector<int> &v = miss_words[*i];

but maybe I'm just getting the whole concept wrong. Any suggestions?
CODE:
void print_map(map<string, vector<int> > miss_words)    // Prints out dictionary set
{
    map<string, vector<int> >::iterator it = miss_words.begin();    // Creates an iterator
    while(it != miss_words.end())           // While hasn't reached the end
    {
        vector<int> &v = miss_words[*it];   // Accesses Vector in map
        for(unsigned int g = 0; g <= v.size(); g++)
        {
            cout<<v.at(g)<<": ";            
            cout<<v.at(g)<<" "<<endl;   // Print out data at i
        }
        it++;                   // Increment iterator
    }
}

The compiler puts says that there is "no match for 'operator[]' in miss_words.

A:

You want to say vector<int> &v = it->second;
The iterator's value type is the value type of the map, i.e. pair<string, vector<int>>.

In fact, in modern C++ you could write this more simply, and less error-prone, like so:
for (auto const & p : miss_words)
{ 
    for (auto const & x : p.second)
    {
        cout << x << ": " << x << " \n";
    }
}

That way, you don't even need to worry about the size of your vector.

