// FILE: copyline.cc #include // required for EXIT_FAILURE etc #include // required for external file streams // COPY ONE LINE OF TEXT FROM ONE FILE TO ANOTHER void copy_line (ifstream& ins, // IN: ins stream ofstream& outs) // OUT: outs stream // Pre: ins is opened for input and outs for output. // Post: Next line of ins is written to outs. // The last character processed from ins is ; // the last character written to outs is . { // Local data ... const char nwln = '\n'; // newline character char next_ch; // inout: character buffer // Copy all data characters from ins file stream to outs file stream. ins.get (next_ch); while ( (next_ch != nwln) && !ins.eof ()) { outs.put (next_ch); ins.get (next_ch); } // end while // If last character read was nwln write it to out_data. if (!ins.eof ()) outs.put (nwln); return; } // end copy_line