C - C++ Streams - Buffer iterator
#include <iostream> #include <iterator> #include <string> using namespace std; int main () { string name; istreambuf_iterator<char> eos; istreambuf_iterator<char> iit (cin.rdbuf()); while (iit!=eos && *iit!='\n') name+=*iit++; cout << "Entered string is " << name << ".\n"; return 0; }