Question: In C++ Rewrite (DO NOT COPY PASTE) the copy program shown below as a reusable function component with two argumentsspecifically, the input and output file

In C++ Rewrite (DO NOT COPY PASTE) the copy program shown below as a reusable function component with two argumentsspecifically, the input and output file streams. The function should return an integer indicating the number of lines copied (0, if the input file is empty). NOTE: You need to create your own file InData.txt with 10 elements.

// File: copyFile.cpp // Copies file InData.txt to file OutData.txt #include // for the definition of EXIT_FAILURE

#include // for external file streams #include using namespace std; // Associate stream objects with external file names #define inFile "InData.txt" // directory name for inFile #define outFile "OutData.txt" // directory name for outFile // Functions used . . . // Copies one line of text int copyLine(ifstream&, ofstream&); int main() { int lineCount; // output: number of lines processed ifstream ins; // ins is an input stream ofstream outs; // outs is an output stream // Open input and output file, exit on any error. ins.open(inFile); // connects ins to file inFile if (ins.fail()) { cerr

cout

// Copy one line of text from one file to another // 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 . // Returns: The number of characters copied. int copyLine (ifstream& ins, // IN: ins stream ofstream& outs) // OUT: outs stream { // Local data . . . const char NWLN = ' '; // newline character char nextCh; // inout: character buffer int charCount = 0; // number of characters copied // Copy all data characters from stream ins to stream outs. ins.get(nextCh); while ((nextCh != NWLN) && !ins.eof()) { outs.put(nextCh); charCount++; ins.get(nextCh); } // end while // If last character read was NWLN write it to outs. if (!ins.eof()) { outs.put(NWLN); charCount++; }

return charCount; } // end copyLine

In C++ Rewrite (DO NOT COPY PASTE) the copy program shown below

Document1 Kyle Schwab File Home Insert DesignLayout References MailingsReviewView Tell me what you want to deo Share tst Enter the Input File name: /Users/RORTA/Temp/InData.txt Enter the outeut F Enter the output File name: /Users/RORTA/Temp/OutData.txt Input file copied to output file lines copied. Program ended with exit code: Page 1 ot 1 0wordsLE + 100% 1:15 AM O Type here to search ^*4) 11/14/2017

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!