C++ examples for STL Algorithm:find
Finds the first object with a specified value with algorithm find()
#include <iostream> #include <algorithm> //for find() using namespace std; int arr[] = { 11, 22, 33, 44, 55, 66, 77, 88 }; int main()/*from w ww . j av a2 s .com*/ { int* ptr; ptr = find(arr, arr+8, 33); //find first 33 cout << "First object with value 33 found at offset " << (ptr-arr) << endl; return 0; }