Your program should read the output of wc as standard input. In another words, the program is to behave as if it were part of the pipeline. Typical execution would be
wc demofile.txt | your_program -[b | w | l]
where your_program is your executable program which will take in the
std::out of wc demofile.txt command as std::in of your program.
The [b | w | l] is the option pass as
command line argument to your program which indicate bytes count, words count or lines count respectively. After reading the inputs, your program should generate a summary report which contains the following information as in the example below:
Example 1:
$ wc demofile.txt | ./program -b
1) The number of files : 1
2) The largest file in byte : demofile.txt (7148 bytes)
3) The smallest file in byte : demofile.txt (7148 bytes) 4) The total number of bytes : 7148 bytes
Example 2:
$ wc *.h | ./program -l
1) The number of files : 6
2) The largest file in line : libaw.h (115 lines) 3) The smallest file in line : mesa.h (39 lines) 4) The total number of lines : 347 lines
Your code contains unexplained identifiers: prev, next, file.
I do recommend that you first read and store all input. You should then have a nice array. From that array you can query the necessary details, as requested by the command line argument. Surely you do know how to find the maximum value from an array?
Are you allowed to understand what the following program does?
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
#include <limits>
int main () {
double max { std::numeric_limits<double>::min() };
double value { 0.0 };
while ( std::cin >> value )
{
if ( max < value ) max = value;
}
std::cout << "Largest value was: " << max << '\n';
return 0;
}