blob: d1762d0bb6665bbf4241a3fbe9bd44d1594fa7ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
struct Buffer {
const char *name;
Page *storage;
Buffer(const char *name) : name(name), storage(new Page()) {}
void read(const char *file) {
FILE *f = fopen(file, "r");
char c;
Point p(storage, 0);
while ((c = fgetc(f)) != EOF) {
p.push(c);
}
fclose(f);
}
void write(const char *file) {
FILE *f = fopen(file, "w+");
for (Point p(storage, 0); !p.at_end(); p++) {
fputc(p.element(), f);
}
fclose(f);
}
};
|