Answers for "c auto iterate map"

C++
0

For auto map C

//Since c++11
for (const auto& kv : myMap) {
    cout << kv.first << " has value " << kv.second << endl;
}
//Since c++17
for (auto& [key, value]: myMap) {
    cout << key << " has value " << value << endl;
}
Posted by: Guest on April-30-2021

Browse Popular Code Answers by Language