Mega Code Archive

 
Categories / C++ / Algorithm
 

Displaying a Containers 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" ) ); }