#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;

int main()
{
    string s="Hello world, isn't this a nice day!\nWhat about tomorrow?\nThen it will be weekend";

    stringstream sstream(s);
    while (sstream)
      {
         string word;
         sstream >> word;            // reads until space(es), lineshift, or EOF. 
         cout << word << "\n";
      }

    char line[256];
    sstream.clear(); // clear failed state.
    sstream.str(s);  // Set string again
    while (sstream)
      {
         sstream.getline(line,256);   // reads until '\n'
         cout << line << "\n";
      }

    return 0;
}

