Output a string with copy function : string output « String « C++






Output a string with copy function

  
#include <algorithm>
#include <iostream>
#include <iterator>
#include <string>
#include <vector>

using namespace std;

int main( )
{

   string s( "this is a test." );
   cout << s << endl;
   copy( s.begin(), s.end(), ostream_iterator<char>( cout, " " ) );
}
  
    
  








Related examples in the same category

1.Read string in and then output
2.Use of as istream_iterator iterator