yo/stl/examples/istreamiterator.cc
raw| 1 | #include <iostream> |
| 2 | #include <iterator> |
| 3 | #include <string> |
| 4 | #include <vector> |
| 5 | #include <algorithm> |
| 6 | using namespace std; |
| 7 | |
| 8 | int main() |
| 9 | { |
| 10 | vector<string> vs; |
| 11 | |
| 12 | copy(istream_iterator<string>(cin), istream_iterator<string>(), |
| 13 | back_inserter(vs)); |
| 14 | |
| 15 | for |
| 16 | ( |
| 17 | vector<string>::const_iterator begin = vs.begin(), end = vs.end(); |
| 18 | begin != end; ++begin |
| 19 | ) |
| 20 | cout << *begin << ' '; |
| 21 | cout << '\n'; |
| 22 | } |