use the contents of strout to create strin : ostrstream « File « C++






use the contents of strout to create strin

  
#include <iostream>
#include <sstream>

using namespace std;

int main()
{
  char ch;
  ostringstream strout;

  strout << 10 << " " << -20 << " " << 30.2 << "\n";
  strout << "This is a test.";

  cout << strout.str() << endl;

  strout << "\nThis is some more output.\n";

  istringstream strin(strout.str());

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

  cout << endl;
}
  
    
  








Related examples in the same category

1.Freeze dynamic buffer and return pointer to it
2.Display the contents of strin via calls to get()
3.construct a table of circular areas