Display the contents of strin via calls to get() : ostrstream « File « C++






Display the contents of strin via calls to get()

  
#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";

  cout << "Use an input string stream called strin.\n";

  // use the contents of strout to create strin:
  istringstream strin(strout.str());

  // Display the contents of strin via calls to get().
  cout << "Here are the current contents of strin via get():\n";
  do {
    ch = strin.get();
    if(!strin.eof()) cout << ch;
  } while(!strin.eof());
}
  
    
  








Related examples in the same category

1.Freeze dynamic buffer and return pointer to it
2.use the contents of strout to create strin
3.construct a table of circular areas