Horje
c++ find element in vector Code Example
c++ find element in vector
auto it = find(vec.begin(),vec,end(), item)!
if(it != vec.end()){
 	 int index = it - vec.begin();
}
vector.find()
#include <algorithm>
#include <vector>

if ( std::find(vec.begin(), vec.end(), item) != vec.end() )
   do_this();
else
   do_that();
c++ vector element search
#include <algorithm>
#include <vector>
vector<int> vec; 
//can have other data types instead of int but must same datatype as item 
std::find(vec.begin(), vec.end(), item) != vec.end()




Cpp

Related
string to int in c++ Code Example string to int in c++ Code Example
swap values in array c++ Code Example swap values in array c++ Code Example
roscpp publish int32 Code Example roscpp publish int32 Code Example
height of bst cpp Code Example height of bst cpp Code Example
recursive power in c++ Code Example recursive power in c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9