Debian Codegraph @

yo/concrete/examples/ifdnbuf.cc

raw
1 #include <unistd.h>
2 #include <iostream>
3 #include <istream>
4 #include "ifdnbuf.h"
5 using namespace std;
6
7 int main()
8 {
9 // internally: 30 char buffer
10 IFdNStreambuf fds(STDIN_FILENO, 30);
11
12 char buf[80]; // main() reads blocks of 80
13 // chars
14 while (true)
15 {
16 size_t n = fds.sgetn(buf, 80);
17 if (n == 0)
18 break;
19 cout.write(buf, n);
20 }
21 }