// Supplementary to "Software Design ...", John A Robinson, Newnes, 2004, // // Remove line numbers from a source code listing that were previously // added by addnumbers // Remove start of each line up to string ": " // John Robinson 7 September 2003 // #include #include #include using namespace std; int main(int argc, char *argv[]) { char linebuffer[2048]; if (argc != 3) { cerr << "Usage: remnumbers in_numbfile out_codefile\n"; return -1; } ifstream infile(argv[1]); if (!infile) { cerr << "Can't open " << argv[1] << endl; return -1; } ofstream outfile(argv[2]); if (!outfile) { cerr << "Can't open " << argv[2] << endl; return -1; } int linenumber = 0; while(1) { infile.getline(linebuffer, 2048, ':'); // Line up to ':' if (infile.eof()) break; infile.getline(linebuffer, 2048, '\n'); // Rest of line outfile << &linebuffer[1] << endl; } infile.close(); outfile.close(); return 0; }