Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
You have a range of elements that you want to print to a stream, most likely cout for debugging.
Write a function template that takes a range or a container, iterates through each element, and uses the copy algorithm and an ostream_iterator to write each element to a stream. If you want more control over formatting, write your own simple algorithm that iterates through a range and prints each element to the stream. (See Example 7-11.)