// modification of istringstream.cc Stephanie Richardson // example of string used as input stream // from http://www.cs.usyd.edu.au/~kev/pp/LECTURES/6a/week6a.html #include #include #include using namespace std; int main() { string line; getline(cin, line); istringstream is(line); int x; while (is >> x) cout << x << endl; is.clear(); // resets the status of the stream see Primer Section 8.2 getline(cin, line); is.str(line); // sets new string to the stream string s; while (is >> s) cout << s << endl; } // see http://www.cplusplus.com/ref/iostream/istringstream/str.html