## 24.6 Stream Iterators - Output Stream Iterators

- Combining stream iterators with various algorithms for simple file processing
- E.g., read integers from stdin, filter out even numbers, write to stdout, one per line:

  >     int main()
  >     {
  >        vector<int> x;
  >        copy(istream_iterator<int>(cin),
  >           istream_iterator(), back_inserter(x));
  >        vector<int>::iterator p =
  >           remove_if(x.begin(), x.end(), is_even);
  >        x.erase(p, x.end());
  >        copy(x.begin(), x.end(),
  >           ostream_iterator<int>(cout, "\n"));
  >        return 0;
  >     }

prev |top |next