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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.