map in c

#include <iostream>
#include <map>

int main() {
    // Step 1: Declare a map with key-value pairs of type int and string
    std::map<int, std::string> myMap;

    // Step 2: Insert key-value pairs into the map
    myMap.insert(std::make_pair(1, "One"));
    myMap.insert(std::make_pair(2, "Two"));
    myMap.insert(std::make_pair(3, "Three"));

    // Step 3: Access elements using the [] operator
    std::cout << "Value at key 2: " << myMap[2] << std::endl;

    // Step 4: Check if a key exists in the map
    if (myMap.find(3) != myMap.end()) {
        std::cout << "Key 3 exists in the map." << std::endl;
    }

    // Step 5: Iterate through the map using iterators
    std::cout << "Map elements: ";
    for (auto it = myMap.begin(); it != myMap.end(); ++it) {
        std::cout << "(" << it->first << ", " << it->second << ") ";
    }
    std::cout << std::endl;

    // Step 6: Erase an element by key
    myMap.erase(2);

    // Step 7: Check if the map is empty
    if (myMap.empty()) {
        std::cout << "Map is empty." << std::endl;
    } else {
        std::cout << "Map is not empty." << std::endl;
    }

    // Step 8: Clear all elements from the map
    myMap.clear();

    return 0;
}