Question: Write the definition of a function named lineCount ( ) that accepts an input file and counts the characters and words in each line, then

Write the definition of a function named lineCount() that accepts an input file and counts the characters and words in each line, then outputs the result with the original text to an output file. The output of character and word counts should be formatted to have a width of 3 spaces respectively. The prototype of lineCount() is given as follows.
int lineCount(ifstream &ifs, ofstream &ofs);
Assume the two files are already open. The return value is the total count of the lines in the input file. A character includes alphabets, digits, spaces and punctuation marks but not newlines. A word is a string of characters separated by whitespaces. For example, lineCount() should return 3 of the following input file:
Love all,
trust a few,
do wrong to none.
and generates the following output file:
92 Love all,
123 trust a few,
174 do wrong to none.

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 Programming Questions!