The following example shows how an ostringstream object is used for an internal write:
#include <iostream> #include <sstream> using namespace std; int main() { int i = 12; float x = 3.14; double y = 1.414; ostringstream oss (ostringstream::out); oss << " write different variable types " << i << ", " << x << ", " << y; fprintf( stderr, "%s\n", oss.str().c_str()); }