Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I display the content of a map on the console?

I have a map declared as follows:

map < string , list < string > > mapex ; list< string > li; 

How can I display the items stored in the above map on the console?

like image 763
Cute Avatar asked Jun 30 '09 12:06

Cute


1 Answers

Update (Back to the future): with C++11 range-based for loops –

std::map<Key, Value> m { ... /* initialize it */ ... };  for (const auto &p : m) {     std::cout << "m[" << p.first << "] = " << p.second << '\n'; } 
like image 111
The Paramagnetic Croissant Avatar answered Sep 30 '22 12:09

The Paramagnetic Croissant