Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Example program
- #include <iostream>
- #include <string>
- #include <sstream>
- using namespace std;
- int first, second;
- string input;
- int main()
- {
- stringstream sstream;
- cout << "First integer: ";
- getline(cin, input);
- sstream.str(input);
- sstream >> first; // state of sstream may be eof
- cout << "Second integer: ";
- getline(cin, input);
- sstream.str(input);
- sstream.clear(); // clear eof state
- sstream >> second; // input from sstream
- }
Add Comment
Please, Sign In to add comment