/* Example of using string streams.
 */

#include <iostream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <sstream>
using namespace std;

int main()
{
  string date = "Independence Day:  July 4, 1776";
 
  istringstream istr(date);

  string word1, word2, month;
  int day, year;
  char comma;
  istr >> word1 >> word2 >> month >> day >> comma >> year;
  cout << "Contents of string stream istr, one word per line:\n"
       << word1 << endl << word2 << endl << month << endl
       << day << comma << endl << year << endl;
  
  int one = 1;
  ofstream outfile("file3-12.out");
  assert(outfile.is_open());

  ostringstream ostr; 

  ostr << "\nNew Year's " << word2 << "  January"
       << setw(2) << one << ", " << year + 224 << endl;
  cout << ostr.str();
  outfile << ostr.str();
  outfile.close();
}  


