Using [] in Map
#include <iostream> #include <map> using namespace std; int main() { map<char, int> mapObject; int i; for(i = 0; i < 26; i++) mapObject.insert(pair<char, int>('A' + i, 65 + i)); char ch; cout << "Enter key: "; cin >> ch; cout << "Its ASCII value is " << mapObject[ ch ]; return 0; }