C++ map find() functionC++ map find() function is used to find an element with the given key value k. If it finds the element then it returns an iterator pointing to the element. Otherwise, it returns an iterator pointing to the end of the map, i.e., map::end(). SyntaxParameterk: It specifies the key to be searched in the map container. Return valueIf it finds the element then it returns an iterator pointing to the element. Otherwise, it returns an iterator pointing to the end of the map i.e. map::end(). Example 1Let's see a simple example to find the element with the given key value. Output: Iterator points to c = 300 In the above example, find() function returns the value of a given key value 'c'. Example 2Let's see a simple example to find the element. Output: Iterator points to e = 500 In the above example, find() function finds the key value e in the map m, if it is not found in the map then it returns a not found message otherwise it will display the map. Example 3Let's see a simple example. Output: Enter the element which you want to search: 4 4 found and the value is 4 = d In the above example, find() function is used to find the element according to user?s given key value. Example 4Let's see a simple example. Output: elements in mymap: a => 50 c => 150 d => 200 Next TopicC++ Map |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India