Determine if map contains a value for a key c++

#include <iostream>
#include <map>

int main() {
    std::map<int, std::string> myMap;

    // Inserting key-value pairs into the map
    myMap[1] = "One";
    myMap[2] = "Two";
    myMap[3] = "Three";

    int keyToCheck = 2;

    // Checking if the map contains a value for the specified key
    auto it = myMap.find(keyToCheck);

    if (it != myMap.end()) {
        // The key is present in the map, and 'it' points to the key-value pair
        std::cout << "Key " << keyToCheck << " found with value: " << it->second << std::endl;
    } else {
        // The key is not present in the map
        std::cout << "Key " << keyToCheck << " not found in the map." << std::endl;
    }

    return 0;
}