Hi,
I have an associative array made up like the following:
I'd like to use a for() to show all the pairs...how can I do that?Code:map<string, string> hash;
thanks
Printable View
Hi,
I have an associative array made up like the following:
I'd like to use a for() to show all the pairs...how can I do that?Code:map<string, string> hash;
thanks
map<string, string>::iterator iter;
for(iter = map.begin();iter!=map.end();++iter)
print(iter->first,iter->second);
where print is your own printing function.
For all STL all containers, there are iterators (or constant iterators) defined that you can access like this (m is a variable of type map<string, string>):
Code:for(std::map<string, string>::iterator it = m.begin(); it!=m.end(); ++it)
{
}
Code:for(std::map<string, string>::const_iterator it = m.begin(); it!=m.end(); ++it)
{
}