stream iterator and copy : ostream_interator « STL Algorithms Iterator « C++ Tutorial






#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
using namespace std;

int main(int argc, char** argv)
{
  vector<int> myVector;
  for (int i = 0; i < 10; i++) {
    myVector.push_back(i);
  }

  // print the contents of the vector
  copy(myVector.begin(), myVector.end(), ostream_iterator<int>(cout, " "));
  cout << endl;
}








30.10.ostream_interator
30.10.1.stream iterator and copy
30.10.2.ostream_iterator for char