Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) std::ostringstream

 

std::ostringstream is an STL output stream interface for std::string manipulation.

 

In the example below, int and std::string are appended to a std::ostringstream, before the std::ostringstream is finally converted to std::string.

 

#include <iostream>
#include <sstream>

int main()
{
  std::ostringstream s;
  const int first_digits = 123;
  const std::string dot = ".";
  const int last_digits = 456;
  s << first_digits << dot << last_digits;
  std::cout << s.str() << '\n';
}

 

 

 

 

 

External links

 

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict