// Code derived from Stroustrup's PPP2 book// § 11.5 Line-oriented input// -and beginning on p 395#include<fstream>#include<iostream>#include<limits>#include<sstream>#include<string>#include<vector>usingnamespacestd;// clears the cin stream for clean reusevoidclear_cin(){cin.clear();cin.ignore(numeric_limits<streamsize>::max(),'\n');// to end-of-line}//------------------------------------------------------------------------------intmain(){{//---cout<<"\n> ";stringname;cin>>name;// input: Dennis Ritchiecout<<name<<'\n';// output: Dennisclear_cin();}{//---cout<<"\n> ";stringname;getline(cin,name);// input: Dennis Ritchiecout<<name<<'\n';// output: Dennis Ritchie}{//---cout<<'\n';stringconstname{"Dennis Ritchie"};stringfirst_name;stringsecond_name;stringstreamss{name};ss>>first_name;// input Dennisss>>second_name;// input Ritchiecout<<first_name<<' '<<second_name<<'\n';// output: Dennis Ritchie}{//---cout<<"\n> ";stringcommand;getline(cin,command);// read the linestringstreamss{command};vector<string>words;for(strings;ss>>s;)words.push_back(s);// extract the individual wordsfor(autoconst&word:words)cout<<word<<'\n';}}