create string stream for input/output : String stream « File « C++






create string stream for input/output

  
#include <iostream>
#include <sstream>

using namespace std;

int main()
{
  char ch;
  stringstream strinout;

  strinout << 10 << " + " << 12 << " is " << 10+12 << endl;

  do {
    ch = strinout.get();
    if(!strinout.eof()) cout << ch;
  } while(!strinout.eof());
  cout << endl;

  strinout.clear();
  strinout << "More output to strinout.\n";

  cout << "the characters just added to strinout:\n";
  do {
    ch = strinout.get();
    if(!strinout.eof()) cout << ch;
  } while(!strinout.eof());
}
  
    
  








Related examples in the same category

1.Demonstrate string streams. Demonstrate string streams.
2.string stream classes in action.