Using STL Find on C++ arrays

by ixmx


#include <algorithm>
 
const int ARRAY_SIZE = 8;
int IntArray[ARRAY_SIZE] = { 1, 2, 3, 4, 4, 5, 6, 7 };
 
int * begin = IntArray;
int * end   = IntArray + ARRAY_SIZE;
 
int value = 5;
 
int *it = find(begin, end, value);
if (it != end)
{// found
	....
}
 

more info on MSDN

Advertisements