Mega Code Archive

 
Categories / C++ Tutorial / STL Algorithms Non Modifying Sequence Operations
 

Demonstrating generic find algorithm with an array

#include <iostream> #include <cassert> #include <algorithm>  // for find using namespace std; int main() {   char s[] = "C++ is a better C";   int len = strlen(s);   // Search for the first occurrence of the letter e:   const char* where = find(&s[0], &s[len], 'e');   cout << *where<< endl;   where = find(&s[0], &s[len], 'A');   cout << *where<< endl;   return 0; } e