Check out example codes for "find in c++". It will help you in understanding the concepts better.

Code Example 1

std::vector<int>::iterator it; 
 
    it = std::find (vec.begin(), vec.end(), ser); 
    if (it != vec.end()) 
    { 
        std::cout << "Element " << ser <<" found at position : " ; 
        std::cout << it - vec.begin() << " (counting from zero) \n" ; 
    } 
    else
        std::cout << "Element not found.\n\n";         

Code Example 2

// CPP program to illustrate  
// std::find 
// CPP program to illustrate  
// std::find 
#include<bits/stdc++.h> 
  
int main () 
{ 
    std::vector<int> vec { 10, 20, 30, 40 }; 
      
    // Iterator used to store the position  
    // of searched element 
    std::vector<int>::iterator it; 
      
    // Print Original Vector 
    std::cout << "Original vector :"; 
    for (int i=0; i<vec.size(); i++) 
        std::cout << " " << vec[i]; 
          
    std::cout << "\n"; 
      
    // Element to be searched 
    int ser = 30; 
      
    // std::find function call 
    it = std::find (vec.begin(), vec.end(), ser); 
    if (it != vec.end()) 
    { 
        std::cout << "Element " << ser <<" found at position : " ; 
        std::cout << it - vec.begin() << " (counting from zero) \n" ; 
    } 
    else
        std::cout << "Element not found.\n\n"; 
          
    return 0; 
}

Code Example 3

// string::find
#include <iostream>       // std::cout
#include <string>         // std::string

int main ()
{
  std::string str ("There are two needles in this haystack with needles.");
  std::string str2 ("needle");

  // different member versions of find in the same order as above:
  std::size_t found = str.find(str2);
  if (found!=std::string::npos)
    std::cout << "first 'needle' found at: " << found << '\n';

  found=str.find("needles are small",found+1,6);
  if (found!=std::string::npos)
    std::cout << "second 'needle' found at: " << found << '\n';

  found=str.find("haystack");
  if (found!=std::string::npos)
    std::cout << "'haystack' also found at: " << found << '\n';

  found=str.find('.');
  if (found!=std::string::npos)
    std::cout << "Period found at: " << found << '\n';

  // let's replace the first needle:
  str.replace(str.find(str2),str2.length(),"preposition");
  std::cout << str << '\n';

  return 0;
}

Code Example 4

size_t find (const string& str, size_t pos = 0) const;

Code Example 5

#include <algorithm>
#include <vector>

if ( std::find(vec.begin(), vec.end(), item) != vec.end() )
   do_this();
else
   do_that();

Learn ReactJs, React Native from akashmittal.com