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 spaces respectively. The prototype of lineCount is given as follows.
int lineCountifstream &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 of the following input file:
Love all,
trust a few,
do wrong to none.
and generates the following output file:
Love all,
trust a few,
do wrong to none.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
