0

Write a program that counts the number of occurrences of selected words in standard input.
Remarks:
• The selected words are given as command line parameters.
• The program should print out the words with their number of occurrences.
Use following definition:
typedef struct {
char * word;
unsigned int counter;
} wordDsc;
The program must have two functions to count the words.
1) The first one (function fixedCount) should use an array of 20 such structures. The function should use a following local array of such structures:
wordDsc fixedSizeArr[20];
2) The second one (function varCount) should use an array of variable size. The function should use the following local pointer to an array of such structures:
wordDsc *varSizeArr;
The size of the array must correspond to the actual number of words that are given by the user.
If the number of words is even use the function fixedCount in the other case use the function varCount.
Test the program using the redirection of standard input and the test.txt file.

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by Ancient Dragon
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.