#include #include #include #include using namespace std; char buf[256]; int index = 0; class mysb : public streambuf { int overflow (int c) { buf[index] = c; buf[index + 1] = 0; index++; if ((index > 200) || (c == '\n')) { printf ("> %s\n", buf); index = 0; } return (1); } int underflow () { return (EOF); } }; int main () { mysb s; streambuf* old; ifstream f ("../mgr/requirements"); if (f) { cout << "opened" << endl; f.close (); } cout << "aaa" << endl; old = cout.rdbuf (&s); //cout = &s; cout << "bbb" << endl; old = cout.rdbuf (old); //cout = old; cout << "ccc" << endl; return (0); }