yo/iostreams/examples/stringstream.cc
raw| 1 | #include <iostream> |
| 2 | #include <sstream> |
| 3 | using namespace std; |
| 4 | |
| 5 | int main(int argc, char **argv) |
| 6 | { |
| 7 | stringstream io; |
| 8 | for (size_t redo = 0; redo != 2; ++redo) |
| 9 | { |
| 10 | io.clear(); // clears the not-good flags |
| 11 | io.str(""); |
| 12 | io << argv[0] << '\n'; |
| 13 | |
| 14 | io.seekg(0); |
| 15 | string line; |
| 16 | while (getline(io, line)) // results in io.eof() |
| 17 | cout << line << '\n'; |
| 18 | } |
| 19 | } |