Debian Codegraph @

yo/iostreams/examples/istringstream.cc

raw
1 #include <iostream>
2 #include <sstream>
3 using namespace std;
4
5 int main()
6 {
7 istringstream istr("123 345"); // store some text.
8 int x;
9
10 istr.seekg(2); // skip "12"
11 istr >> x; // extract int
12 cout << x << '\n'; // write it out
13 istr.seekg(0); // retry from the beginning
14 istr >> x; // extract int
15 cout << x << '\n'; // write it out
16 istr.str("666"); // store another text
17 istr >> x; // extract it
18 cout << x << '\n'; // write it out
19 }
20 /*
21 output of this program:
22 3
23 123
24 666
25 */