#include <string>
#include <sstream>
#include <iostream>
void outputfunc(std::ostream* output)
{
// a function that prints stuff to the given ostream 'output'
*output << "example";
*output << "example";
*output << "example";
}
int main()
{
// print some stuff to cout:
outputfunc( &std::cout );
// print some stuff to a string:
std::stringstream ss;
outputfunc( &ss );
std::string str = ss.str();
// here, 'str' is a string containing "exampleexampleexample"
}