Mega Code Archive

 
Categories / C++ / Algorithm
 

Using find with normal iteration

#include <iostream> #include <vector> #include <algorithm> // for find #include <iterator> using namespace std; int main() {   string s("It is him.");   vector<char> vector1(s.begin(), s.end());   ostream_iterator<char> out(cout, " ");   vector<char>::iterator i = find(vector1.begin(), vector1.end(), 'i');   cout << "chars from the first i to the end: ";   copy(i, vector1.end(), out); cout << endl;   return 0; } /*  chars from the first i to the end: i s   h i m .  */