Debian Codegraph @

yo/concrete/streambuf/fdstreambuf/fdinseek.cc

raw
1 #include "fdstreambuf.h"
2 #include <string>
3 #include <iostream>
4 #include <istream>
5 #include <iomanip.h>
6
7 using namespace std;
8
9 int main(int argc)
10 {
11 fdstreambuf
12 fds(0, ios::in);
13 istream
14 is(&fds);
15 string
16 s;
17
18 cout << "START\n";
19
20 while (true)
21 {
22 if (!getline(is, s))
23 break;
24
25 streampos
26 pos = is.tellg();
27
28 cout << setw(5) << pos << ": `" << s << "'\n";
29
30 if (!getline(is, s))
31 break;
32
33 streampos
34 pos2 = is.tellg();
35
36 cout << setw(5) << pos2 << ": `" << s << "'\n";
37
38 if (!is.seekg(pos))
39 {
40 cout << "Seek failed\n";
41 return 1;
42 }
43 }
44 }