Question: C program to run on ubuntu to find the total count of words and optionally the longest and/or shortest words in a string input by
C program to run on ubuntu to find the total count of words and optionally the longest and/or shortest words in a string input by the user or coming from a file. If there is no filename the user would be prompted to enter the string. You must use getopt to parse the command line. The string would not be input on the command line.
Usage: countwords [-l] [-s] [filename]
* The l option means to find the longest word in the string.
* The s option means to find the shortest word in the string.
* You may have both or one of the options.
* Running with no options returns the count of the number of words that would be entered at the command line. Pressing enter would end the string.
* Running with a filename only would return the count of the number of words in the first string in the file.
* -l option without a filename returns the number of words and the actual longest word.
* -l option with a filename returns the number of words and the actual longest word in the first sentence of the file
* -s option without a filename returns the number of words and the actual longest word.
* -s option with a filename returns the number of words and the actual longest word in the first sentence of the file
* -l and -s option together without a filename returns the number of words and the actual longest and shortest words. The entry string would end when the user pressed enter.
* -l and -s option together with a filename returns the number of words and the actual longest and shortest words. The entry string would end when the user pressed enter.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
