Question
Write a program that will process one or more files and print out various statistics for these files. The file names should be provided via
Write a program that will process one or more files and print out various statistics for these files. The file names should be provided via command line arguments or the program will simply use stdio stream to get input if there are no command line arguments.
If the user does not provide any command line arguments, the input should be read from the stdio stream instead of a standard file. If the user provides one or more command line arguments the program should process files with the names provided by command line arguments one by one and print out statistics for each file separately. If more files are processed, summary statistics should also be printed out.
The program should display the following statistics for each file (also summary statistics if multiple files are processed) :
1. Number of characters in the file
2. Number of lines in the file (i.e. number of newline characters)
3. Number of words in the file. A word is a sequence of any characters except for the space, newline or tabulator characters not separated by these characters. Therefore, in a string "This is the first line This \t\this the 2nd" we would have 9 words ( and \t are the special characters).
The program will be similar to the wc command provided in Linux. Use the functions defined in ctype.h. For example, isspace is a good function to identify white space and distinguish it from the rest.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started