|
#include <iostream>
#include <istream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iterator>
using namespace std;
int main( ) {
cout << "Enter a series of strings: ";
istream_iterator<string> start(cin);
istream_iterator<string> end;
vector<string> v(start, end);
vector<string>::iterator p = partition(v.begin( ), v.end( ),bind2nd(less<string>( ), "foo"));
cout << "*p = " << *p << endl;
}
/*
Enter a series of strings: a b c
a s c
de
foo
*p = s
Terminate batch job (Y/N)? n
*/
|
Tags: C, Code, istream iterator, istream iterator laquo STL Algorithms Iterator laquo C, Read string from keyboard and save to vector directly, STL Algorithms Iterator
Posted in Uncategorized |
This entry was posted
on Saturday, July 4th, 2009 at 1:27 am and is filed under Uncategorized.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.