Description

Write a program that accepts as input an ASCII string (a word) of max length 20 characters. This word is the search term that your program will use. It should then read in the remaining input text (e.g. a poem), which features a series of lines (each of no more than 100 characters in length) comprising zero or more words (each of at most 20 characters) in ASCII (which may include some punctuation characters that must be removed). Your C program should process that text into a series of individual words (i.e. strings separated from one another by space, comma or full-stop), filter any non alphabetic characters from the words, and compare them with the search word. A count of the number of times the search word is found in the text should be maintained, and printed out at the end of the processing.

The output should be the search word, along with a count of how many times that word was found in the text.

Input

A word of at most 20 characters on a line on its own, followed by a number of lines of text (each of 100 characters at most, featuring 0 or more words of at most 20 characters each)

Output

The search word, followed by a "=>" string and then an integer count of how many times that word was found in the text.

Sample Input

jabberWock
The Jabberwock
Twas brillig, and the slithy toves
Did gyre and gimble in the wabe:
All mimsy were the borogoves,
And the mome raths outgrabe.
Beware the Jabberwock, my son!
The jaws that bite, the claws that catch!
Beware the Jubjub bird, and shun
The frumious Bandersnatch!
He took his vorpal sword in hand;
Long time the manxome foe he sought
So rested he by the Tumtum tree
And stood awhile in thought.
And, as in uffish thought he stood,
The Jabberwock, with eyes of flame,
Came whiffling through the tulgey wood,
And burbled as it came!
One, two! One, two! And through and through
The vorpal blade went snicker-snack!
He left it dead, and with its head
He went galumphing back.
And hast thou slain the Jabberwock?
Come to my arms, my beamish boy!
O frabjous day! Callooh! Callay!
He chortled in his joy.
Twas brillig, and the slithy toves
Did gyre and gimble in the wabe:
All mimsy were the borogoves,
And the mome raths outgrabe.

Sample Output

jabberWock=>4

HINT

It is easier to compare two strings if they are converted to uppercase (or to lowercase) first.

Your program needs to process text until an EOF is encountered (indicating the end of the text). When testing your program yourself (not via online judge), it is difficult to generate an EOF on some platforms. It is simpler to prepare your test input data in a text file, and then pipe that data into your program using "<" e.g. if your program has been compiled into the a.out file then:

./a.out < sourcetext.txt

will send the contents of sourcetext.txt into your program, and when all the contents of that file have been processed, your program will receive an EOF on the input stream.

You might find the string library function strtok() useful to solve this problem.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.