[Solved] How to access particular elements in a multi-map C++ [closed]


Although it would be easier to help you if you were to post a minimal reproducible example, as text, formatted as a code sample, I think I still understand what you’re asking.

This looks like a learning exercise that you want to solve on your own. But I can give some advice.

What you want to do is check two conditions: that you’ve read five elements, or that you’ve run out of them. Declare both a loop counter initialized to 0 and an iterator.initialized to .begin(). Loop until the counter is equal to 5 or the iterator is equal to .end(). On each iteration, increment both the counter and the iterator. You might express this as a while loop, but you could also do it with comma operators in your for loop.

Also, please indent your code properly and use braces under your for and if statements. It’ll save you from writing a lot of bugs and make your code much easier to read.

0

solved How to access particular elements in a multi-map C++ [closed]