Write C Language that will be able to open a file specified on the command line and process that. Your program should still be able to process from stdin but only if the given filename is '-'.
this program will use an allocated struct to hold the word content and the occurrence count. The collection of word structs will be a a linked list stored in sorted order by the word content. Treat words as singleton's in your program - only one copy exists.
This program will also maintain a linked list for each line in the source file. Each line will be a linked list with a pointer to each word that appears in the line.
This should look for WC_DEBUG as an environment variable and if set totrueshould be treated as if -d option was provided on the command line.
Additional option to support will be:-ofilepathSpecifies output file instead of stdout.
-l -- report the line count (that is a lower case L) -c -- report the character count-w -- report the word count-f -- report each word and its frequency
-v -- reports all information (equivalent to all options -l -c -w -f)-h -- prints a brief synopsis on how to use your program-d -- print to stderr debugging information as your program progresses -ofilepath-- Output report to file specified infilepath
7.my_file :
8.word_count : 2
9.line_count : 2
10.char_count : 12
11.word_frequency :
12.word1 : 1
13.word2 : 1
Test:
How much wood could a woodchuck
chuck if a woodchuck
could chuck
wood?
Expected Output
my_wc.test1.in :
word_count : 13
line_count : 3
char_count : 72
word_frequency :
how : 1
much : 1
wood : 1
could : 2
a : 2
woodchuck : 2
chuck : 2
if : 1
wood? : 1
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here