how to find a particular element in vector c++ code example
Example 1: vector.find()
#include <algorithm>
#include <vector>
if ( std::find(vec.begin(), vec.end(), item) != vec.end() )
do_this();
else
do_that();
Example 2: c++ find element in vector
auto it = find(vec.begin(),vec,end(), item)!
if(it != vec.end()){
int index = it - vec.begin();
}