findif0.cpp

findif0.cpp

#include ‹stl.h›

#include ‹iostream.h›

bool odd(int a_) {

 return a_ % 2;

}

int numbers[6] = {2, 4, 8, 15, 32, 64};

int main() {

 int* location = find_if(numbers, numbers + 6, odd);

 if (location != numbers + 6)

  cout ‹‹ "Value " ‹‹ *location ‹‹ " at offset " ‹‹ (location - numbers) ‹‹ " is odd" ‹‹ endl;

 return 0;

}