#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
bool iscomma(char ch) {
if(ch == ',')
return true;
return false;
}
int main()
{
vector<char> vectorObject;
vector<char>::iterator p;
char str[] = "One, Two, Three, Four, Five, Six";
int i;
for(i = 0; i < strlen(str); i++)
vectorObject.push_back(str[ i ]);
cout << "Contents of vectorObject: ";
for(i = 0; i < vectorObject.size(); i++)
cout << vectorObject[ i ];
cout << endl;
p = find(vectorObject.begin(), vectorObject.end(), 'T'); // find the first T
cout << "Sequence beginning with T: ";
while(p != vectorObject.end())
cout << *p++;
cout << endl;
p = find_if(vectorObject.begin(), vectorObject.end(), iscomma); // find first comma
cout << "After find first comma: ";
while(p != vectorObject.end())
cout << *p++;
cout << endl;
return 0;
}
|