ostream_iterator Print tool

The ostream_iterator is an Output Iterator that performs formatted output of objects of type T to a particular ostream. Not that all of the restrictions of an Output Iterator must be obeyed.

Example 1:
copy the elements of a vector to the standard output, one per line.
vector vectorData;
copy(vectorData.begin(), vectorData.end(), ostream_iterator(cout, "\n"));


Example 2:
copy the cha** data to the standard output, one per line.
char** charData= new char*[2];
copy(charData.begin(), charData.end(), ostream_iterator(cout, "\n"));

No comments:

Post a Comment