Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Latest commit

History

History
26 lines (21 loc) 路 646 Bytes

find.md

File metadata and controls

26 lines (21 loc) 路 646 Bytes

find

Description : The map::find() is a function which returns an iterator through which the key and value pair can be accessed. If not found the iterator returns map.end()

Example :

// Demonstrates find() 
#include <iostream>
#include <map> 
  
int main() { 
    // declaration of map container
    std::map<int, int> mymap;
    mymap[0] = 10;
    mymap[1] = 11; 
    mymap[2] = 12; 
    mymap[3] = 13; 

    // using find() function
    auto itr = mymap.find(1);
    std::cout << "The value at position " << itr->first << " is " << itr->second << "\n";
    return 0; 
} 

Run Code