Skip to content

Instantly share code, notes, and snippets.

@jflopezfernandez
Created May 7, 2018 14:29
Show Gist options
  • Save jflopezfernandez/b85e5e75ca87d9d542d348890e195a5f to your computer and use it in GitHub Desktop.
Save jflopezfernandez/b85e5e75ca87d9d542d348890e195a5f to your computer and use it in GitHub Desktop.
Printing the contents of a stream buffer using an iterator
#include <iostream>
#include <iterator>
#include <string>
int main()
{
const std::string text("Hello, my name is Jean-Pierre Williams.");
std::ostreambuf_iterator<char> bufferWriter(std::cout);
std::copy(text.begin(), text.end(), bufferWriter);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment