stringstream::str( ) returns a string : stringstream « File Stream « C++ Tutorial






#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>

using namespace std;

int main( ) {
  stringstream ss;
  ss << "string " << 9 << 1.2;

  cout << ss.str( ) << endl;   // stringstream::str( ) returns a string
}
string 91.2








12.20.stringstream
12.20.1.Demonstrate string streams
12.20.2.Use stringstream to parse a number
12.20.3.stringstream::str( empty string): Empty the string
12.20.4.stringstream::str( ) returns a string