Last change
on this file since 668 was
11,
checked in by arnault, 20 years ago
|
Changing eol-style property
|
-
Property svn:eol-style set to
native
|
File size:
747 bytes
|
Line | |
---|
1 | #include <stdio.h> |
---|
2 | #include <stdlib.h> |
---|
3 | #include <iostream> |
---|
4 | #include <fstream> |
---|
5 | |
---|
6 | using namespace std; |
---|
7 | |
---|
8 | char buf[256]; |
---|
9 | int index = 0; |
---|
10 | |
---|
11 | class mysb : public streambuf |
---|
12 | { |
---|
13 | int overflow (int c) |
---|
14 | { |
---|
15 | buf[index] = c; |
---|
16 | buf[index + 1] = 0; |
---|
17 | index++; |
---|
18 | if ((index > 200) || (c == '\n')) |
---|
19 | { |
---|
20 | printf ("> %s\n", buf); |
---|
21 | index = 0; |
---|
22 | } |
---|
23 | return (1); |
---|
24 | } |
---|
25 | int underflow () |
---|
26 | { |
---|
27 | return (EOF); |
---|
28 | } |
---|
29 | }; |
---|
30 | |
---|
31 | int main () |
---|
32 | { |
---|
33 | mysb s; |
---|
34 | streambuf* old; |
---|
35 | |
---|
36 | ifstream f ("../mgr/requirements"); |
---|
37 | if (f) |
---|
38 | { |
---|
39 | cout << "opened" << endl; |
---|
40 | f.close (); |
---|
41 | } |
---|
42 | |
---|
43 | cout << "aaa" << endl; |
---|
44 | |
---|
45 | old = cout.rdbuf (&s); |
---|
46 | //cout = &s; |
---|
47 | |
---|
48 | cout << "bbb" << endl; |
---|
49 | |
---|
50 | old = cout.rdbuf (old); |
---|
51 | //cout = old; |
---|
52 | |
---|
53 | cout << "ccc" << endl; |
---|
54 | |
---|
55 | return (0); |
---|
56 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.