Answers for "can map return a value to a variable in c++"

C++
0

can map return a value to a variable in c++

#include <iostream>  
#include <map>  
using namespace std;  
int main(void) {  
   map<char, int> m = {  
            {'a', 100},  
            {'b', 200},  
            {'c', 300},  
            {'d', 400},  
            {'e', 500},  
            };  
              
    auto it = m.find('e');  
     
    if ( it == m.end() ) {  
    // not found  
     cout<<"Element not found";  
    }   
    else {  
        // found  
        cout << "Iterator points to " << it->first << " = " << it->second << endl;  
    }  
      
   return 0;  
}
Posted by: Guest on March-05-2022

Code answers related to "can map return a value to a variable in c++"

Browse Popular Code Answers by Language