Displaying a Container's Elements on the Standard Output with copy function
#include <algorithm>
#include <iostream>
#include <iterator>
#include <string>
#include <vector>
using namespace std;
int main( )
{
vector<int> v( 5, 9 );
copy( v.begin(), v.end(), ostream_iterator<int>( cout, " " ) );
copy( v.begin(), v.end(), ostream_iterator<int>( cout, "\n" ) );
}
Related examples in the same category