/* Program: EPRINT.CPP Author : Kim Moser Date : 08/20/1992 System : IBM PC / Borland C++ 3.0 Descrip: Filters text files, changing formfeed (CTRL-L) characters into appropriate number of newlines. Usage : EPRINT #include static void usage(void); static void usage(void) { cerr << "usage: eprint [lines_per_page] prn:\n"; } void main(int argc, char **argv) { long linesperpage = 66; long line=0, page=0; char ch; if (argc > 1) { if ((linesperpage = atoi(argv[1])) <= 0) { usage(); } cerr << '(' << linesperpage << " lines per page)\n"; } // Turn off whitespace-skipping for input: cin.unsetf(ios::skipws); while (!((cin >> ch).eof())) { switch (ch) { case 12: // Formfeed (CTRL-L) while (line++ < linesperpage) { cout << '\n'; } page++; line = 0; break; case '\n': if (++line >= linesperpage) { line = 0; page++; } // Fall through default: cout << ch; break; } } cerr << '\n' << page << " page(s), " << line << " line(s)\n" << '(' << ((page)*linesperpage + line) << " line(s) total)\n"; }