File inf,outf;
int ip,op;
int i;
Tuple t;
Buffer buf,obuf;
inf = openFile(fileName("S"), READ);
outf = openFile(fileName("T"), CREATE);
clear(obuf);
for (ip = op = 0; ip < nPages(inf); ip++) {
buf = readPage(inf, ip);
for (i = 0; i < nTuples(buf); i++) {
t = getTuple(i, buf);
addTuple(t, obuf);
if (isFull(obuf)) {
writePage(outf, op++, obuf);
clear(obuf);
} } }
if (nTuples(obuf) > 0) writePage(outf, op, obuf);
|